Skip to content

Commit

Permalink
[3.0.x] Fixed #31342 -- Clarified docs about using base managers for …
Browse files Browse the repository at this point in the history
…related objects.

Backport of 08a6215 from master
  • Loading branch information
carltongibson authored and felixxm committed Mar 6, 2020
1 parent e3069f6 commit 1c1911d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/topics/db/managers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ 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>`.

Base managers 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.
Base managers aren't used when querying on related models, or when
:ref:`accessing a one-to-many or many-to-many relationship
<backwards-related-objects>`. 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 1c1911d

Please sign in to comment.