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