Django:如何匹配数据库中的空值
通过使用 django ORM:如何匹配数据库中的结果不为空?
example_objects = Example.objects.filter(field !=null)
我不确定如何编写该过滤器来获取所有非空记录。
By using django ORM: How to match the result in database is NOT null?
example_objects = Example.objects.filter(field !=null)
I'm not sure about how to write that filter to get all non-null records.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为您正在寻找:
或:
I think you're looking for either:
or:
怎么样?
example_objects = Example.objects.exclude(field =null)
how about
example_objects = Example.objects.exclude(field =null)
?使用 NullBooleanField 如下:
Use NullBooleanFeild as below::