Opened 15 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 Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 15 years ago

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.

comment:3 by Matt McClanahan, 14 years ago

Severity: Normal
Type: Bug

comment:4 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Honza Král, 12 years ago

Owner: changed from nobody to Honza Král
Status: newassigned

comment:8 by Russell Keith-Magee, 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 Honza Kral <honza.kral@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In 4ad1eb1c14b629cf5bcfd253ed40e875f1bddd47:

Fixed #12674 -- provide a way to override admin validation

Moved admin validation code to classes and have those be class
attributes to the ModelAdmin classes.

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