I'm running Django 1.7 and I'm getting TypeError: unsupported operand type(s) for |: 'bool' and 'Q'
when trying to do the following:
class PersonList(generic.ListView):
template_name = "persons/list.html"
model = Person
queryset = Person.objects.filter(Q(field1__isnull=True | Q(field2__isnull=True)))
In the example code, brackets are not where they are supposed to be when working with models.Q
.
Solution:
Person.objects.filter(Q(field1__isnull=True) | Q(field2__isnull=True))
Mind the closing bracket.