Skip to content Skip to sidebar Skip to footer

Logical Operations In Django Filter

I need to get my queryset where: (a='a' AND b=None) OR (a=None AND b='b') I know about Q objects in django, but this syntax doesn't works: cls.objects.filter(models.Q(a='a', b

Solution 1:

cls.objects.filter(models.Q(a="a", b='None') | models.Q(a='None' AND b="b"))

try this


Post a Comment for "Logical Operations In Django Filter"