Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#13035 closed (fixed)

Wrong documentation for admin and default managers

Reported by: rasca Owned by: Gabriel Hurley
Component: Documentation Version: dev
Severity: Keywords: manager objects admin docs
Cc: rasca7@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When creating custom models managers the docs say:

If you use custom Manager objects, take note that the first Manager Django encounters (in the order in which they're defined in the model) has a special status. Django interprets this first Manager defined in a class as the "default" Manager, and several parts of Django (though not the admin application) will use that Manager exclusively for that model. As a result, it's often a good idea to be careful in your choice of default manager, in order to avoid a situation where overriding of get_query_set() results in an inability to retrieve objects you'd like to work with.

So if in a model I have

new = NewManager()
objects = models.Manager()

the admin should work as if there isn't any NewManager but it doesn't

The following works as desired:

objects = models.Manager()
new = NewManager()

Attachments (1)

13035_managers_docs_patch.diff (1.1 KB ) - added by Gabriel Hurley 15 years ago.
Fixes some outdated information about default managers and contrib.admin

Download all attachments as: .zip

Change History (9)

comment:1 by Gabriel Hurley, 15 years ago

Owner: changed from nobody to Gabriel Hurley
Status: newassigned
Triage Stage: UnreviewedDesign decision needed

Confirmed that this behavior occurs as reported. I'm not sure which way it's *supposed* to work currently... Whether the code should be brought back in line with the docs or the docs need to be changed to reflect the code!

comment:2 by Gabriel Hurley, 15 years ago

Triage Stage: Design decision neededAccepted

Looking at the history of tickets related to admin and _default_manager, it appears this is the intended behavior, and the docs are simply (very) outdated here. I'll add a patch to remove that "though not admin" bit.

by Gabriel Hurley, 15 years ago

Fixes some outdated information about default managers and contrib.admin

comment:3 by Gabriel Hurley, 15 years ago

Has patch: set

comment:4 by Gabriel Hurley, 15 years ago

Summary: Wrong documentaion or bad admin behaviourWrong documentation for admin and default managers

comment:5 by Gabriel Hurley, 15 years ago

Component: django.contrib.adminDocumentation

This ended up being a docs bug, so I'm re-categorizing it.

comment:6 by Luke Plant, 15 years ago

Resolution: fixed
Status: assignedclosed

(In [12930]) Fixed #13035 - Incorrect documentation regarding admin and default managers

Thanks to rasca for report and gabrielhurley for patch

comment:7 by Luke Plant, 15 years ago

(In [12931]) [1.1.X] Fixed #13035 - Incorrect documentation regarding admin and default managers

Thanks to rasca for report and gabrielhurley for patch.

Backport of r12930 from trunk

comment:8 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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