#34178: Prefetching a foreign key on GenericForeignKey results in incorrect
queryset being selected
-------------------------------------+-------------------------------------
Reporter: Rohan Nahata | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: GenericForeignKey, | Triage Stage:
prefetch_related | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Rohan Nahata):
Replying to [comment:2 Mariusz Felisiak]:
> `QuerySet.prefetch_related()` works with `GenericForeignKey`, however it
is only supported if the query is restricted to one `ContentType` (see
`prefetch_related()`
[https://docs.djangoproject.com/en/stable/ref/models/querysets/#prefetch-
related docs]).
>
> Duplicate of #33651.
Just a question regarding this. Wouldn't this be the wrong behaviour
though? It silently does the wrong thing instead of erroring out.
--
Ticket URL: <https://code.djangoproject.com/ticket/34178#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/01070184a3e4bf06-f869e6eb-c53b-469a-9685-8f880ff7eb09-000000%40eu-central-1.amazonses.com.