Z
Z
zyusifov112021-06-04 10:56:14
Django
zyusifov11, 2021-06-04 10:56:14

How to get related objects?

class Logotype(models.Model):
    brand = models.ForeignKey('Brand', on_delete=models.PROTECT)
    logo = models.TextField(null=True, unique=True)
    hasSvg = models.BooleanField(default=False)
    views = models.IntegerField(null=True)
    date = models.DateField(default=datetime.now())
    is_active = models.BooleanField(default=True)

class Brand(models.Model):
    brand = models.TextField(unique=True)


obj = Brand.objects.filter(
        brand__icontains=query, "как получить только те у которых is_active=True")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-06-04
@dmtrrr

https://docs.djangoproject.com/en/3.2/topics/db/ex...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question