1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #30355 -- Doc'd interaction between custom managers and prefetch_related().

This commit is contained in:
Akash Kumar Sen 2023-05-26 21:28:59 +05:30 committed by Mariusz Felisiak
parent 7cc138a58f
commit 5f2308710b

View File

@ -1790,6 +1790,18 @@ methods::
b.entry_set(manager="entries").is_published()
.. admonition:: Interaction with prefetching
When calling :meth:`~django.db.models.query.QuerySet.prefetch_related` with
a reverse relation, the default manager will be used. If you want to
prefetch related objects using a custom reverse manager, use
:class:`Prefetch() <django.db.models.Prefetch>`. For example::
from django.db.models import Prefetch
prefetch_manager = Prefetch("entry_set", queryset=Entry.entries.all())
Blog.objects.prefetch_related(prefetch_manager)
Additional methods to handle related objects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~