I have the same problem as OP in this thread: Django - filtering by "certain value or None":
I have a field in an data object that can be either null or set to some integer. I want, given an integer, to filter all the objects with that integer value OR none:
MyElements.objects.all().filter(value__in=[myInt, None]) # Query 1
However, this line does not work for elements with null value. More precisely:
MyElements.objects.all().filter(value__in=[None]) # Query 2
returns nothing. whereas
MyElements.objects.all().filter(value = None) # Query 3
returns the null-valued elements.
How can I rewrite the original query (which involves myInt) correctly?
I am aware that OP has accepted an answer, but I would like to know why Query 2
did not yield any results.