summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAkash Kumar Sen <Akash-Kumar-Sen@users.noreply.github.com>2023-05-26 21:28:59 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-06-07 19:32:18 +0200
commiteb84c068ed7c2982389b8d331418e99dd9709ff7 (patch)
tree412db7f182319644a9404e276f45bb2bc794943a /docs
parentb2355a8df308b160b1a20b2263faf4238b32a371 (diff)
[4.2.x] Fixed #30355 -- Doc'd interaction between custom managers and prefetch_related().
Backport of 5f2308710b5a3d9f5f135b7ade08214f5c154ec4 from main
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/queries.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 7c6c9e18ac..84fbfabe45 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -1802,6 +1802,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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~