[Answered ]-Django ModelAdmin Fieldset within fieldset

2👍

Unfortunately you’re out of luck, the Django admin does not support nested fieldsets and has no way to output other structural tags, except by customising the templates.

You can have a look at:
http://django-betterforms.readthedocs.org/en/latest/basics.html

It supports nested fieldsets, so this code will help you when you are customising your admin templates.

0👍

If you are trying to create a page something like this :

enter image description here

Then you can add following to your admin file :

from django.contrib import admin

class FlatPageAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': ('url', 'title', 'content', 'sites')
        }),
        ('Advanced options', {
            'classes': ('collapse',),
            'fields': ('registration_required', 'template_name'),
        }),
    )

And for more details you can check this page

0👍

It looks like Django still doesn’t support nested fieldsets (April 2022).

Instead, I had to go through and organize my fieldsets into tuples

('Water Conveyance', {
    'classes': ('collapse',),
    'fields': (('spillway_gate', 'bypass_valve'), ('trash_exclusion', 'intake_gate', 'intake_passage', 'shutoff_valve'), ('cone', 'isolation'))
}),

And then set verbose_name on all my field definitions

spillway_gate = models.CharField(max_length=25, choices=Key.choices, default=Key.default, verbose_name="Bypass - Spillway Gate")
bypass_valve = models.CharField(max_length=25, choices=Key.choices, default=Key.default, verbose_name="Bypass - Bypass Valve")

Not as pretty, but it works

Screenshot

Leave a comment