开发者

How to get database records only with filled field?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜