Django: How to match null in database
By using django ORM: How to match the result in database is NOT null?
example_objects = Example.ob开发者_开发技巧jects.filter(field !=null)
I'm not sure about how to write that filter to get all non-null records.
I think you're looking for either:
Example.objects.filter(field__isnull=False)
or:
Example.objects.exclude(field__isnull=True)
example_objects = Example.objects.exclude(field=None)
how about
example_objects = Example.objects.exclude(field =null)
?
Use NullBooleanFeild as below::
happy = models.NullBooleanField(null=True, blank=True)
精彩评论