wagtail-nest / wagtail-modeladmin

Add any model in your project to the Wagtail admin. Formerly wagtail.contrib.modeladmin.
Other
21 stars 8 forks source link

Improve consistency of how views in ModelAdmin are initialised #12

Open ababic opened 7 years ago

ababic commented 7 years ago

In modeladmin, there's a bit of inconsistency in how the views are initialised. There's a distinction between 'Instance specific' views (those that sub-class wagtail.contrib.modeladmin.views.InstanceSpecificView) and the other views.

Really, there's no need for the __init__() method of InstanceSpecificView to be any different to that of WMABaseView (the only important thing for modeladmin views at initialisation is the linking to a ModelAdmin instance). The instance_pk should be provided to dispatch() instead, and dealt with appropriately there. This would give us:

The only thing I'm not sure about is backwards compatibility / deprecation, since we're currently telling people in the docs to copy from current examples to implement custom views... so that's potentially a big issue.

Any input / thoughts from others would be much appreciated.