Opened 16 years ago
Closed 12 years ago
#12674 closed Bug (fixed)
Admin validation doesn't reflect ModelAdmin's extensibility
| Reported by: | Honza Král | Owned by: | Honza Král |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
If you choose to extend ModelAdmin in a non standard way - for example overriding get_changelist, Django still validates it using django.contrib.admin.validation which has no clue on what options are valid for your ModelAdmin class.
By design if you validate something that can be extended/changed/substituted for something it must be either optional (not run whenever you try to access your admin in debug mode) or extensible itself (moved to the classes in question - ModelAdmin, ChangeList etc).
Change History (9)
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 16 years ago
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:6 by , 13 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:7 by , 13 years ago
Code can be found here:
https://github.com/HonzaKral/django/compare/master...ticket-12674
comment:8 by , 12 years ago
| Patch needs improvement: | set |
|---|
I've reviewed this; there's a couple of minor things that I've flagged in the inline comments, but for the most part it looks good.
comment:9 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
An example, because it took me a couple of seconds to catch on - imagine you overwrote get_changelist(), and made it use the value in the list_display property of ModelAdmin. However, your revised get_changelist() doesn't use the same format as the stock list_display (e.g., it expects a list of classes, not a list of strings). The ModelAdmin validation will raise an error because list_display doesn't validate to ModelAdmin's default behavior, even though that behaviour isn't necessarily being used.
This might just be a matter of making validate() a method on ModelAdmin that can be overridden like anything else.