D
D
Daniil Chernov2021-08-04 13:26:12
Django
Daniil Chernov, 2021-08-04 13:26:12

How to get queryset where attribute is not empty?

Let's say there is a model

class A(models.Model):
    name = models.CharField(max_length=200, verbose_name='Название')
    com = models.TextField(blank=True, null=True, verbose_name='Комментарий')


And here I want to get a list in the display where name='Name', and com is not empty:

Something like this:
hochu_eto = A.objects.filter(name='Имя', com is not None)


How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-08-04
@dancha

A.objects.filter(name='Имя', com__isnull=False)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question