3 ms·
It's been a bit since I've used Django, but I believe you can just swap the order so the kwarg comes last. filter( Q(column_b__isnull=True)|Q(column_b=
by squeaky-clean 3y ago
It's been a bit since I've used Django, but I believe you can just swap the order so the kwarg comes last.
filter( Q(column_b__isnull=True)|Q(column_b='value2'),
column_a='value1',
)
Or just turn it into another Q
.filter(Q(column_a='value1'), Q(column_b__isnull=True)|Q(column_b='value2'))
- Izkata 3y agoThe docs show both of those as working examples, but Q supports using & for "and", and can be combined in any way - you could also do this: .filter(Q(column_a='value1') & (Q(column_b__isnull=True) | Q(column_b='value2')))