Opened 6 years ago

Closed 8 months ago

#10938 closed New feature (duplicate)

add inlines into fieldsets

Reported by: ctao Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords: inlines fieldsets
Cc: cg@…, ckesselh, gargr, gezuru@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description (last modified by aaugustin)

'ModelAdmin has fieldsets and inlines. e.g.
Ref: http://docs.djangoproject.com/en/dev/intro/tutorial02/,

fieldsets = [
        (None,               {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date']}),
    ]

inlines = [ChoiceInline]

If can put the inlines into the fieldsets, it would be great. such as:

fieldsets = [
        (None,               {'fields': ['question']}),
        ('inlines sample',   {inlines : [ChoiceInline]}),
        ('Date information', {'fields': ['pub_date']}),
        ('inlines sample 2', {inlines : [SomeOtherChoiceInline]}),
    ]

Change History (17)

comment:1 Changed 6 years ago by ctao

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Or such as:

fieldsets = [
        (None,               {'fields': ['question']}),
        ('inlines sample',   {inlines : [ChoiceInline]}),
        ('Date information', {'fields': ['pub_date']}),
        ('inlines sample 2', {inlines : [SomeOtherChoiceInline]}),
        ('inlines sample 3', {inlines : ['fieldA', 'fieldB', ]}),
    ]

comment:2 Changed 5 years ago by gmorehoudh

Bump -- I finally managed to find this bug and find that there is apparently no way to accomplish this. It's surprising. This feature would be quite useful.

comment:3 Changed 5 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

I'm not sure I agree that this would be an improvement. Feel free to open a discussion on django-dev if you disagree.

comment:4 Changed 4 years ago by EnTeQuAk

  • Cc cg@… added

comment:5 Changed 4 years ago by melinath

  • Easy pickings unset
  • Resolution wontfix deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Triage Stage changed from Unreviewed to Accepted
  • Type set to New feature
  • UI/UX set
  • Version changed from 1.0 to SVN

Reopened as per discussion on django developers. Since inlines already have a label (in the form of verbose_name) and can control their fields etc., perhaps the following syntax would make more sense:

fieldsets = (
    (None, {'fields': 'field1', 'field2'}),
    SomeInline,
    ("Remaining Fields", {'fields': 'field3', 'field4', 'field5'})
)

comment:6 Changed 4 years ago by aaugustin

  • Description modified (diff)
  • Owner changed from nobody to aaugustin
  • Status changed from reopened to new

comment:7 Changed 4 years ago by julien

See also #4848, which suggests supporting inlines declaration via ModelAdmin.fields. #16089 might also be of interest, as it discusses adding the ability to dynamically add and remove inlines on a per-request basis.

comment:8 Changed 4 years ago by ckesselh

  • Cc ckesselh added

comment:9 Changed 4 years ago by gargr

  • Cc gargr added

comment:10 Changed 3 years ago by stormlifter

Part of the issue I see is that if you are overriding another app's forms then it would be nice to be able to use an inline and add that into the fieldset so that you don't have to redo everything. For example...

class UserProfileInline(admin.TabularInline):
	model = UserProfile

class UserAdmin(UserAdmin):
	inlines = [UserProfileInline]

The sytax that melinath suggest isn't bad. Another idea would be to call a special method that allows you to insert the Inline at a specified index. So you could say in the example of melinath "fieldsets.inject(1,SomeInline)" which would put the fieldsets from SomeInline into the fieldsets of the parent at that location.

The issue I am getting is that since the fieldsets are unable to include any inline fields that the fields from the inline model are always forced to the bottom, of course I could use JS to move them to the top, but that's just boring. I could also override the form and make it save that added field to the appropriate model, but that's just sloppy.

Last edited 3 years ago by stormlifter (previous) (diff)

comment:11 Changed 3 years ago by aaugustin

  • Owner changed from aaugustin to nobody

comment:12 Changed 3 years ago by gezuru@…

  • Cc gezuru@… added

comment:13 Changed 3 years ago by gezuru@…

  • Resolution set to duplicate
  • Status changed from new to closed

With the syntax proposition by melinath this ticket has become a duplicate of #4848.

comment:14 Changed 3 years ago by anonymous

  • Resolution duplicate deleted
  • Status changed from closed to reopened

comment:15 Changed 3 years ago by aaugustin

  • Resolution set to duplicate
  • Status changed from reopened to closed

Please don't reopen tickets anonymously without providing an explanation. You may have a good reason for reopening this ticket; if so, say it!

comment:16 Changed 8 months ago by neamat@…

  • Resolution duplicate deleted
  • Status changed from closed to new

comment:17 Changed 8 months ago by charettes

  • Resolution set to duplicate
  • Status changed from new to closed

Please don't reopen tickets anonymously without providing an explanation. You may have a good reason for reopening this ticket; if so, say it!

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