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 :
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
- [Answered ]-Django queries does datatype matter?
- [Answered ]-Couldn't import django in virtualenv but works when deactivated
- [Answered ]-Where to put static files in Django apps or project
- [Answered ]-Django saving choices values
- [Answered ]-KeyError overriding django ModelAdmin.get_readonly_fields()
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
- [Answered ]-Handling Multiple Views/ Multiple Urls in Django
- [Answered ]-Is it possible to do case-insensitive ordering in descending order with the Django ORM
- [Answered ]-Django saving choices values
Source:stackexchange.com