18👍
✅
You can use Q values which allow you to combine multiple clauses in Django querysets.
Your query set would be something like:
from django.db.models import Q
MyElements.objects.all().filter(Q(value=None) | Q(value=myInt))
7👍
You can try OR statement:
from django.db.models import Q
MyElements.objects.filter(Q(value__isnull=True) | Q(value=myInt))
- Django AttributeError: 'DatabaseOperations' object has no attribute 'select'
- Testing authentication in Django Rest Framework Views — Cannot authenticate when testing
- Django models – assign id instead of object
- How to serialize an 'object list' in Django REST Framework
Source:stackexchange.com