#32281: Prefetech Object - to_attr has ambiguous behavior when using a related
lookup
-------------------------------------+-------------------------------------
Reporter: Tal Perry | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* resolution: => wontfix
Comment:
> In our use case, we're assigning a filtered queryset to the prefetch
object .
>
> {{{
> annotations = Prefetch(
> "tokens__tagged_tokens", queryset=tagged_token_qs,
to_attr="annotations",
> )
> }}}
>
> In the above example it's not clear whether the resulting prefetch will
bring all tokens, or only those tokens who have a tagged_token in the
supplied queryset.
>
> Perhaps the solution is as simple as making this explicit in the docs.
Happy to contribute if that's the right way and someone can shed light on
the behavior and any edge cases.
I'm not sure how this question is related with the ticket. It's explicitly
stated in
[https://docs.djangoproject.com/en/3.1/ref/models/querysets/#django.db.models.Prefetch
docs]:
> The queryset argument supplies a base QuerySet for the given lookup.
[https://docs.djangoproject.com/en/stable/internals/contributing/triaging-
tickets/#closing-tickets Please follow triaging guidelines with regards to
wontfix tickets.]
--
Ticket URL: <https://code.djangoproject.com/ticket/32281#comment:3>
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/066.a65cc924efbdff74da1b019be9044230%40djangoproject.com.