开发者

django finding model (profile) empty fields

i have user and profile models i want to find which fields of profile are empty for each user.

something like empty_field_users=User.objects.filter(profile__fields='')

for instance

if my profile has fields like

name logo description

and user did not fill out something to description and saved his profile. i want 开发者_如何学运维to get this user in empty_field_users

thanks in advance


As far as I can see what you have specified should work fine, assuming 'description' is a non-null field with a default empty string value.

no_description = User.objects.filter(profile__description='')

If it is a null field, you can do it like this:

no_description = User.objects.filter(profile__description__isnull=True)

Docs here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜