Opened 14 years ago
Closed 5 years ago
#15859 closed New feature (duplicate)
Allow more precise placement of admin inlines
Reported by: | Owned by: | ||
---|---|---|---|
Component: | contrib.admin | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
I just had to copy django/contrib/admin/templates/admin/change_form.html (bad!) for wholesale replacement in my site for an easily fixable reason: I wanted my TabularInline to show at the top of the change form for my model, not at the bottom.
Inlines are for composition of a form, they're not a second-class citizen like "related objects". As such, I believe there should be a way to allow someone to at least choose top or bottom.
Change History (8)
comment:1 by , 14 years ago
Version: | 1.2 → 1.3 |
---|
comment:2 by , 14 years ago
Summary: | Allow placement of admin inline models → Allow more precise placement of admin inlines |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
Easy pickings: | unset |
---|
For the top/bottom case (not arbitrary placement), there appears to be a pretty simple solution from my digging around.
Add a 'position' class variable to InlineModelAdmin (just like 'extra'). From there, it's a matter of tweaking the template(s) to have a top and bottom loop over the standard inline_admin_formsets, but include a conditional that checks for 'top' (or whatever) in the top loop, and 'bottom' in the bottom loop.
If that's not feasible, it's less simple, but not a total nightmare. I think add_view() and change_view() would need to be tweaked in contrib/admin/options.py to build both top_inline_admin_formsets and bottom_inline_admin_formsets (with corresponding template tweaks).
Just offering what I dug up. Don't assume I have any real clue.
EDIT: No idea why my update above unset "Easy pickings". I didn't do it!
comment:4 by , 14 years ago
UI/UX: | set |
---|
comment:5 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 12 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Owner: | removed |
Status: | assigned → new |
Here is some work I did on making this possible: https://github.com/django/django/pull/793
When defining your Admin Inline in admin.py you simply set "display_at_top = True" and this will now cause the inline to display at the top of the page.
If you do not define "display_at_top" it just defaults to displaying at the bottom.
comment:7 by , 11 years ago
Needs documentation: | set |
---|
I agree. It would be even better if one could insert inlines between fieldsets.