[Django] #31342: Default manager vs Base manager for RelatedManager

17 views
Skip to first unread message

Django

unread,
Mar 5, 2020, 4:22:31 AM3/5/20
to django-...@googlegroups.com
#31342: Default manager vs Base manager for RelatedManager
--------------------------------------------+-------------------------
Reporter: Benjamin Mampaey | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 2.2
Severity: Normal | Keywords: manager
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------------+-------------------------
The documentation on Base Managers
https://docs.djangoproject.com/en/2.2/topics/db/managers/#base-managers is
confusing or incomplete.

It specifies "By default, Django uses an instance of the
Model._base_manager manager class when accessing related objects (i.e.
choice.question), not the _default_manager on the related object."

But when accessing the set of related objects, i.e. question.choice_set,
it is the default manager that is used. This does not appear clearly in
the documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/31342>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 5, 2020, 10:09:13 AM3/5/20
to django-...@googlegroups.com
#31342: Default manager vs Base manager for RelatedManager
--------------------------------------+------------------------------------

Reporter: Benjamin Mampaey | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: manager | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* version: 2.2 => 3.0
* type: Uncategorized => Cleanup/optimization
* easy: 1 => 0
* stage: Unreviewed => Accepted


Comment:

Hi Benjamin.

This comes up every so often — it's hard stuff.

The docs have:

> Base managers aren’t used when querying on related models.

But I think the required information is really in the Making Queries topic
page. I've [https://github.com/django/django/pull/12531 suggested a PR]
adding a link back to the
[https://docs.djangoproject.com/en/3.0/topics/db/queries/#following-
relationships-backward Following relationships backward] section there.
Hopefully that's clearer.

Thanks for the report.

--
Ticket URL: <https://code.djangoproject.com/ticket/31342#comment:1>

Django

unread,
Mar 5, 2020, 10:12:41 AM3/5/20
to django-...@googlegroups.com
#31342: Default manager vs Base manager for RelatedManager
--------------------------------------+------------------------------------

Reporter: Benjamin Mampaey | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: manager | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31342#comment:2>

Django

unread,
Mar 5, 2020, 10:14:24 AM3/5/20
to django-...@googlegroups.com
#31342: Default manager vs Base manager for RelatedManager
-------------------------------------+-------------------------------------
Reporter: Benjamin Mampaey | Owner: Carlton
Type: | Gibson
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: manager | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: nobody => Carlton Gibson
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31342#comment:3>

Django

unread,
Mar 6, 2020, 5:43:50 AM3/6/20
to django-...@googlegroups.com
#31342: Default manager vs Base manager for RelatedManager
-------------------------------------+-------------------------------------
Reporter: Benjamin Mampaey | Owner: Carlton
Type: | Gibson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.0
Severity: Normal | Resolution: fixed

Keywords: manager | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1c1911dcd9480ddc23a64703027cc78b379bc011" 1c1911d]:
{{{
#!CommitTicketReference repository=""
revision="1c1911dcd9480ddc23a64703027cc78b379bc011"
[3.0.x] Fixed #31342 -- Clarified docs about using base managers for
related objects.

Backport of 08a6215d334f88f16707278e6003af59d13345b4 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31342#comment:4>

Reply all
Reply to author
Forward
0 new messages