#26379: Document that first `.filter()` chained to a RelatedManager is sticky
-------------------------------+------------------------------------
Reporter: Balázs Oroszi | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Jacob Walls):
* component: Database layer (models, ORM) => Documentation
* summary: Inconsistent behaviour of filter() on related model
(RelatedManager) => Document that first `.filter()` chained to a
RelatedManager is sticky
Comment:
#36617 was a dupe. Based on the answer in comment:5, on the advice of
comment:1 I'm reframing this as a documentation issue.
As pointed out in #36617, when the
[https://docs.djangoproject.com/en/5.2/topics/db/queries/#spanning-multi-
valued-relationships spanning multi-valued relationships example]
describes "restrictive" and "permissive" queries, it implies that chaining
filter calls always creates a permissive query. From the discussion it's
not clear what effect chaining `.filter()` on a RelatedManager has. Is it
a "distinct" filter with respect to the filter baked into the
RelatedManager? Answer, no: the first filter is "sticky". Subsequent
filter calls are distinct.
See a shell example in ticket:36617#comment:3. See
[https://groups.google.com/g/django-
developers/c/dpL5z1yOe58/m/msQTmGwMCAAJ mailing list archive] for more on
"sticky" filters.
--
Ticket URL: <https://code.djangoproject.com/ticket/26379#comment:7>
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 visit
https://groups.google.com/d/msgid/django-updates/01070199791ba7ba-bedfcc10-c5a2-450b-ad37-fc3671906fc8-000000%40eu-central-1.amazonses.com.