5👍
✅
If you want to display all the emails that are not empty (filter-out empty) then you can exclude them using
users = User.objects.exclude(email__isnull=True)
If you want to get all the columns with empty email value then use
users = User.objects.filter(email__isnull=True)
1👍
Declare model:
class User(models.Model):
email = models.EmailField(null=True)
then:
users = User.objects.filter(email__isnull=True)
If you want to exclude empty value then:
users = User.objects.exclude(email__isnull=True)
- [Django]-Django openid authentication with google
- [Django]-Check_object_permissions with CreateAPIView
- [Django]-Django annotate multiple objects based on multiple fields on a M2M relationship
- [Django]-Parse textarea line by line (or a specific line #) with Django
- [Django]-Syntax error whenever I put Python code inside a Django template
Source:stackexchange.com