#12004 closed (fixed)
Registering abstract model with admin gives confusing / misleading error
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | How to create a pull request | ||
Description ¶
It makes perfect sense that an abstract model cannot be registered with admin. However, the abstract model is listed with the rest and there is no error until the page for that model is requested from the admin interface. Doing so gives:
'str' object has no attribute '_default_manager'
This is a bit mysterious, and IMO would be better handled at the time of registering the model with something more explicit. Also, since this error occurs in some other hard-to-identify cases (see #10405, among others), I spent a lot of time going down blind alleys in search of the source of the problem.
Change History (9)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Has patch: | set |
---|
by , 14 years ago
Attachment: | fix12004.patch added |
---|
by , 14 years ago
Attachment: | 12004_admin_abstract_models.py added |
---|
by , 14 years ago
Attachment: | 12004_admin_abstract_models.diff added |
---|
Patch with correct diff extension
comment:3 by , 14 years ago
milestone: | → 1.3 |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Thank you mk for your patch. I've just updated the message in the exception and simplified the tests (no need to have a special url or AdminSite object).
by , 14 years ago
Attachment: | 12004_admin_abstract_models.2.diff added |
---|
Simplified test and move it to a better home (regressiontests/admin_registration/)
This patch changes admin.site.register to raise an ImproperlyConfigured exception if someone tries to register an abstract model with the administration.
Unit test included.