Opened 5 years ago

Closed 5 years ago

#31342 closed Cleanup/optimization (fixed)

Default manager vs Base manager for RelatedManager

Reported by: Benjamin Mampaey Owned by: Carlton Gibson
Component: Documentation Version: 3.0
Severity: Normal Keywords: manager
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (4)

comment:1 by Carlton Gibson, 5 years ago

Easy pickings: unset
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization
Version: 2.23.0

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 suggested a PR adding a link back to the Following relationships backward section there. Hopefully that's clearer.

Thanks for the report.

comment:2 by Carlton Gibson, 5 years ago

Has patch: set
Last edited 5 years ago by Mariusz Felisiak (previous) (diff)

comment:3 by Carlton Gibson, 5 years ago

Owner: changed from nobody to Carlton Gibson
Status: newassigned

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 1c1911d:

[3.0.x] Fixed #31342 -- Clarified docs about using base managers for related objects.

Backport of 08a6215d334f88f16707278e6003af59d13345b4 from master

Note: See TracTickets for help on using tickets.
Back to Top