Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve consistency of how views in ModelAdmin are initialised #12

Open
ababic opened this issue Feb 20, 2017 · 0 comments
Open

Improve consistency of how views in ModelAdmin are initialised #12

ababic opened this issue Feb 20, 2017 · 0 comments

Comments

@ababic
Copy link

ababic commented Feb 20, 2017

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:

  • A way to truly 'genericise' the various action_view() methods on the ModelAdmin class (as currently being proposed in Simplify adding new views to ModelAdmin #10) without having to add special treatment for certain actions.
  • Views that are easier to understand, and easier for developers to reuse.
  • Fetching the object in dispatch would mean we have access toHttpRequest object, so we could reuse ModelAdmin.get_queryset() to get a base queryset from which to search for an instance, rather than just using the default manager's get_queryset() method.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants