Opened 14 years ago

Closed 5 years ago

#15859 closed New feature (duplicate)

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

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 Jeff Blaine <jblaine@…>, 14 years ago

Version: 1.21.3

comment:2 by Julien Phalip, 14 years ago

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 by Jeff Blaine, 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!

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

comment:4 by Julien Phalip, 13 years ago

UI/UX: set

comment:5 by Hodson, 12 years ago

Owner: changed from nobody to Hodson
Status: newassigned

comment:6 by Hodson, 12 years ago

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

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 Tim Graham, 11 years ago

Needs documentation: set

comment:8 by frnhr, 5 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #4848

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