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 11:48:01 +0200
commit5f2308710b5a3d9f5f135b7ade08214f5c154ec4 (patch)
tree6af9e05363b21b94d1df3ed4f9498dbd0bb5b42b /docs
parent7cc138a58f73c17f07cfaf459ef8e7677ac41ac0 (diff)
Fixed #30355 -- Doc'd interaction between custom managers and prefetch_related().
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 b33530bc88..6dfe97f317 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~