#30355: Specifying custom manager doesn't work with prefetch
-------------------------------+-------------------------------------------
Reporter: Kyle Mulka | Owner: Akash Kumar Sen
Type: Bug | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------------
Comment (by Akash Kumar Sen):
The possible explanation here is that {{{queryset}}} generated with
{{{prefetch}}} does not modify the queryset or make a DB query when we are
fetching the reviews, this is the sole purpose of prefetch, so if we try
to use a {{{custom manager}}} with {{{prefetch}}} that will violate the
purpose of using prefetch, hitting 1 extra query every time we try to
fetch the reviews.
I will update the docs with this explanation for better understanding
along with the alternative way using from {{{django.db.models.Prefetch}}}.
Attaching the testcase for better understanding: https://github.com/Akash-
Kumar-Sen/django/blob/ticket_30355_3/tests/dummy_tests/tests.py.
Some feedbacks willbe helpful as I still have a little confusion.
--
Ticket URL: <https://code.djangoproject.com/ticket/30355#comment:11>
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/0107018880b09a18-cee08c95-67f7-40fb-a10c-e39b264050d4-000000%40eu-central-1.amazonses.com.