[Django] #36631: Support nested relations in FilteredRelation's condition is broken

3 views
Skip to first unread message

Django

unread,
Sep 28, 2025, 10:06:35 PM (2 days ago) Sep 28
to django-...@googlegroups.com
#36631: Support nested relations in FilteredRelation's condition is broken
-------------------------------------+-------------------------------------
Reporter: nad2000 | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: 5.2 | Severity: Normal
Keywords: FilteredRelation | Triage Stage:
nested relations | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The support of nested relations in FilteredRelation, implemented with
#29789 Support nested relations in FilteredRelation's condition (3.2), is
broken:

This bug resurfaced with 5.2. (after upgrading from 5.1.9). The queryset
causing this issue ("ValueError: FilteredRelation's condition doesn't
support nested relations deeper than the relation_name (got
'conflict_of_interestspanellistuser' for 'conflict_of_interests')."):


{{{#!python
queryset = queryset.filter(round__panellists__user=user,
state="submitted").annotate(
coi=FilteredRelation(
"conflict_of_interests",
condition=Q(conflict_of_interests__panellist__user=user),
)
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36631>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 29, 2025, 8:53:39 AM (2 days ago) Sep 29
to django-...@googlegroups.com
#36631: Support nested relations in FilteredRelation's condition is broken
-------------------------------------+-------------------------------------
Reporter: nad2000 | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: FilteredRelation | Triage Stage:
nested relations | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: => duplicate
* status: new => closed

Comment:

Duplicate of ticket:29789#comment:30
--
Ticket URL: <https://code.djangoproject.com/ticket/36631#comment:1>

Django

unread,
Sep 29, 2025, 8:55:14 AM (2 days ago) Sep 29
to django-...@googlegroups.com
#36631: Support nested relations in FilteredRelation's condition is broken
-------------------------------------+-------------------------------------
Reporter: nad2000 | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: FilteredRelation | Triage Stage:
nested relations | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):

If you provide your models, we can verify that the error is working as
intended. As described in ticket:29789#comment:31, it looks like Django
5.1.9 failed to raise an error in this case (you could verify by adding
`__exact` to the lookup).
--
Ticket URL: <https://code.djangoproject.com/ticket/36631#comment:2>

Django

unread,
Sep 29, 2025, 8:56:16 AM (2 days ago) Sep 29
to django-...@googlegroups.com
#36631: Support nested relations in FilteredRelation's condition is broken
-------------------------------------+-------------------------------------
Reporter: nad2000 | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: FilteredRelation | Triage Stage:
nested relations | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: duplicate => worksforme

--
Ticket URL: <https://code.djangoproject.com/ticket/36631#comment:3>
Reply all
Reply to author
Forward
0 new messages