Opened 5 years ago

Last modified 3 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 5 years ago by Jeff Blaine <jblaine@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.2 to 1.3

comment:2 Changed 5 years ago by julien

  • Summary changed from Allow placement of admin inline models to Allow more precise placement of admin inlines
  • Triage Stage changed from Unreviewed to Accepted

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

comment:3 Changed 5 years ago by jblaine

  • 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.

Version 0, edited 5 years ago by jblaine (next)

comment:4 Changed 5 years ago by julien

  • UI/UX set

comment:5 Changed 4 years ago by Hodson

  • Owner changed from nobody to Hodson
  • Status changed from new to assigned

comment:6 Changed 4 years ago by Hodson

  • Has patch set
  • Needs tests set
  • Owner Hodson deleted
  • Status changed from assigned to new

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 3 years ago by timo

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