summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-08-16 13:12:55 -0400
committerTim Graham <timograham@gmail.com>2016-08-16 13:13:10 -0400
commit8df2da36379cfce0efc7f2da96fc076ed221dc0a (patch)
tree1f7e7b6471d0647cbf3801613c28d8a56ceac826
parent020ba4bf91aec9b13f415ace5cd538958ce3b608 (diff)
[1.10.x] Fixed #19222 -- Documented that default managers aren't used for related queries.
Backport of 8fb53c50ce1c759c740960c9e1cef3cef39cabc5 from master
-rw-r--r--docs/topics/db/managers.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/topics/db/managers.txt b/docs/topics/db/managers.txt
index db17354633..db147cfb37 100644
--- a/docs/topics/db/managers.txt
+++ b/docs/topics/db/managers.txt
@@ -204,7 +204,7 @@ Using managers for related object access
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, Django uses an instance of the ``Model._base_manager`` manager
-class when accessing related objects (i.e. ``choice.poll``), not the
+class when accessing related objects (i.e. ``choice.question``), not the
``_default_manager`` on the related object. This is because Django needs to be
able to retrieve the related object, even if it would otherwise be filtered out
(and hence be inaccessible) by the default manager.
@@ -214,6 +214,12 @@ appropriate for your circumstances, you can tell Django which class to use by
setting :attr:`Meta.base_manager_name
<django.db.models.Options.base_manager_name>`.
+Manager's aren't used when querying on related models. For example, if the
+``Question`` model :ref:`from the tutorial <creating-models>` had a ``deleted``
+field and a base manager that filters out instances with ``deleted=True``, a
+queryset like ``Choice.objects.filter(question__name__startswith='What')``
+would include choices related to deleted questions.
+
Don't filter away any results in this type of manager subclass
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~