开发者

How to get database records only with filled field?

开发者 https://www.devze.com 2023-03-26 04:06 出处:网络
I have model w开发者_运维知识库ith an optional ForeignKey field. I need filter all records with filled this field. How do I do this?Model.objects.exclude(foreignkey__isnull=True)

I have model w开发者_运维知识库ith an optional ForeignKey field. I need filter all records with filled this field. How do I do this?


Model.objects.exclude(foreignkey__isnull=True)

or

Model.objects.filter(foreignkey__isnull=False)
0

精彩评论

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