开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜