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)
精彩评论