{{{
from django.db import models
from django.db.models import Q
class Test(models.Model):
pass
out = Test.objects.none()
for a, b in [(1,1),(2,2),(3,3)]:
out |= Q(a=a, b=b)
> out
> Out[23]: <Q: (OR: (AND: ('a', 1), ('b', 1)), (AND: ('a', 2), ('b', 2)),
(AND: ('a', 3), ('b', 3)))>
}}}
In django 4.1 it's resulting in an AttributeError
{{{
site-packages/django/db/models/query.py:1951, in
QuerySet._check_operator_queryset(self, other, operator_)
1950 def _check_operator_queryset(self, other, operator_):
-> 1951 if self.query.combinator or other.query.combinator:
1952 raise TypeError(f"Cannot use {operator_} operator with
combined queryset.")
AttributeError: 'Q' object has no attribute 'query'
}}}
This error (or feature?) seems to come from #33127
--
Ticket URL: <https://code.djangoproject.com/ticket/33963>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.