2π
β
It is based on SQL rules for execution. NULL values are not actual values to be compared. itβs an unknow value.
read more about this here: is null vs == null
In Django you can get records with NULL values like that:
MyElements.objects.filter(value__isnull = True)
So you need to first filter None
out your list of comparisons and add it to your query by yourself.
from django.db.models import Q
MyElements.objects.filter(Q(value__in = [list_of_vals]) | Q(value__isnull = True))
π€Ramy M. Mousa
1π
You should test if a field is null using the isnull
filter instead; otherwise in SQL any value compared to a null value would always evaluate as false:
from django.db.models import Q
MyElements.objects.filter(Q(value=myInt) | Q(value__isnull=True))
π€blhsing
Source:stackexchange.com