Opened 8 years ago

Last modified 5 years ago

#15859 new New feature

Allow more precise placement of admin inlines

Reported by: Jeff Blaine <jblaine@…> 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


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 (7)

comment:1 Changed 8 years ago by Jeff Blaine <jblaine@…>

Version: 1.21.3

comment:2 Changed 8 years ago by Julien Phalip

Summary: Allow placement of admin inline modelsAllow more precise placement of admin inlines
Triage Stage: UnreviewedAccepted

I agree. It would be even better if one could insert inlines between fieldsets.

comment:3 Changed 8 years ago by Jeff Blaine

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/ 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!

Last edited 8 years ago by Jeff Blaine (previous) (diff)

comment:4 Changed 8 years ago by Julien Phalip

UI/UX: set

comment:5 Changed 6 years ago by Hodson

Owner: changed from nobody to Hodson
Status: newassigned

comment:6 Changed 6 years ago by Hodson

Has patch: set
Needs tests: set
Owner: Hodson deleted
Status: assignednew

Here is some work I did on making this possible:

When defining your Admin Inline in 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 Changed 5 years ago by Tim Graham

Needs documentation: set
Note: See TracTickets for help on using tickets.
Back to Top