Fieldset tabs allow you to organize form fields into a tabbed interface, making complex forms more manageable and improving the user experience.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/unfoldadmin/django-unfold/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Fieldset tabs enable you to group related fields into tabs within your ModelAdmin’s change form. This is particularly useful for models with many fields or complex data structures.
Basic Setup
Create fieldset tabs by adding thetab class to your fieldsets:
admin.py
The
tab class in the classes list converts a fieldset into a tab. Each fieldset with the tab class becomes a separate tab in the interface.Tab Requirements
For a fieldset to be recognized as a tab, it must meet these requirements:- Include
'tab'in theclasseslist - Have a name (the first element of the fieldset tuple)
- The name must be a non-empty string
admin.py
Active Tab Detection
The system automatically determines which tab should be active:- If there are validation errors, the first tab with errors is activated
- Otherwise, the first tab is activated by default
admin.py
The active tab is determined using the
tabs_active template tag, which checks for field errors in each fieldset.Error Indication
Tabs with validation errors are automatically highlighted with a badge showing the error count:admin.py
Combining Tabs with Other Fieldset Options
Fieldset tabs support all standard Django fieldset options:admin.py
You can combine the
tab class with other classes like collapse, wide, or custom CSS classes.Readonly Fields in Tabs
Readonly fields work seamlessly within fieldset tabs:admin.py
Inline Fields Within Tabs
You can include inline-style fields within tabs:admin.py
Best Practices
Group related fields
Group related fields
Use descriptive tab names
Use descriptive tab names
Choose clear, concise names that describe the content of each tab.
Prioritize important fields
Prioritize important fields
Place the most frequently used or important fields in the first tab.
Limit the number of tabs
Limit the number of tabs
Keep the number of tabs reasonable (ideally 3-7) to avoid overwhelming users.
Add/Change Form Variations
You can use different fieldsets for add and change forms:admin.py
The
add_fieldsets attribute is respected by Unfold’s ModelAdmin. Use it to provide a simplified form for creating new objects.Technical Details
Must include
'tab' for the fieldset to be rendered as a tab.unfold.templatetags.unfold.tabs- Extracts tab fieldsetsunfold.templatetags.unfold.tabs_active- Determines active tabunfold.templatetags.unfold.tabs_errors_count- Counts errors per tab
Related Features
Inline Tabs
Organize multiple inlines in tabs
Model Tabs
Configure navigation tabs for models
Forms Overview
Learn about Unfold’s form system
Conditional Fields
Show/hide fields based on conditions