#33963: Combining Q objects
-------------------------------------+-------------------------------------
Reporter: Bogumil | Owner: nobody
Schube |
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Working example with django 4.0
{{{
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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070182e8f176ac-3e083512-6b45-48e0-8342-e6496a0df78c-000000%40eu-central-1.amazonses.com.