#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)
Change History (9)
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 15 years ago
Triage Stage: | Design decision needed → Accepted |
---|
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 , 15 years ago
Attachment: | 13035_managers_docs_patch.diff added |
---|
Fixes some outdated information about default managers and contrib.admin
comment:3 by , 15 years ago
Has patch: | set |
---|
comment:4 by , 15 years ago
Summary: | Wrong documentaion or bad admin behaviour → Wrong documentation for admin and default managers |
---|
comment:5 by , 15 years ago
Component: | django.contrib.admin → Documentation |
---|
This ended up being a docs bug, so I'm re-categorizing it.
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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!