Opened 10 years ago
Closed 10 years ago
#23280 closed New feature (needsinfo)
Allow easy overriding of admin rendering helpers.
Reported by: | Adam Avramov | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | admin, helpers |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The classes in question -- the ones that reside in django.contrib.admin.helpers
-- play a fundamental role in rendering admin forms; yet their entire existence is woefully undocumented, and the code only references them in passing in the middle of complex view code, effectively turning a crucial part of the rendering process into a black box, and thus precluding a whole lot of customization opportunities which would otherwise be accessible to the (ostensibly) few of us who love contrib.admin
and use it as a go-to framework for the more formulaic CRUD projects out there.
The one minor contribution I've made to the Django codebase so far -- namely merging add_view
and change_view
into changeform_view
on a nice Cardiff Sunday -- unintentionally made overriding helpers slightly easier, by introducing the get_inline_formsets
method, where InlineAdminFormSet
could be replaced with a custom subclass without much ado. Replacing AdminForm
, however, still requires copying the big blob of code that is changeform_view
and modifying it in place -- hardly good OOP practice.
Adding a way to specify custom helper classes would require only trivial changes to the admin
codebase, so if anyone else thinks I've got a point, let me know and I can come up with a patch/PR.
Change History (2)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
I am in favor of trying to remove these helpers as much as possible and move functionality (where/if it makes sense) into model form/formset, etc. It's also nice not to make everything (these classes) a public API so we can more easily make changes without worrying about backwards compatibility. Maybe if you can enumerate some use cases for customizing these classes we can work on a plan for how to make this easier.