#26518: Refactor admin view functions to allow for easier overrides
-------------------------------+--------------------
Reporter: aventurella | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Currently the admin views hosted in django.contrib.admin.options are
pretty monolithic in their implementation. That's not necessarily a bad
thing until a user needs to override only a portion of the view logic. In
which case the whole view function needs to be overridden which is not
ideal as that overridden view now needs to keep pace with any changes in
Django releases.
This ticket proposes enhancing the various admin views to begin to allow
some designated, override points, for example, modify the context or
placing the TemplateResponse into a separate function.
Modify the context after it's been generated could be something like:
{{{
# changelist_view
context = self.update_changelist_view_context(request, context)
#delete_view
context = self.update_delete_view_context(request, context)
}}}
These could initially just be a noop, but a user would be able to easily
add additional information or make modifications if necessary.
Similarly, moving the TemplateResponse's into functions would also allow
for cleaner composition when creating new view handling overrides, for
example:
{{{
self.render_changelist_view_template(
request,
default=self.change_list_template,
app_label=app_label,
model_name=opts.model_name,
context=context
)
}}}
This would obviously not address all potential enhancements, but things
gotta start somewhere.
--
Ticket URL: <https://code.djangoproject.com/ticket/26518>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.6b5969b3ebd6f745d107c8d3c84e5fc0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.