Model tabs provide a powerful navigation system that allows you to create custom tab-based navigation across different models, views, and pages in your Django admin interface.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
Model tabs are configured at the site level and allow you to group related models or views into a tabbed interface. This is useful for creating dashboard-like views or organizing related administrative tasks.
Configuration
Model tabs are configured in your admin site settings using theTABS configuration:
admin.py
Model tabs are defined in the
TABS configuration and can be customized per request.Tab Structure
Each tab configuration consists of:List of model identifiers that should display these tabs. Can be strings in
'app.model' format or dictionaries with additional options.List of tab items to display. Each item must have
link and title properties.Specific page identifier if tabs should only appear on certain pages (e.g.,
'changelist', 'changeform').Basic Example
Create tabs for filtering products by status:admin.py
Model-Specific Tabs
You can specify different tabs for changelist and detail views:admin.py
Use the
detail key in model dictionaries to control whether tabs appear on the changelist (detail=False) or change form (detail=True).Page-Specific Tabs
Tabs can be limited to specific page types:admin.py
Dynamic Tab Generation
Generate tabs dynamically based on user permissions or other criteria:admin.py
Active Tab Detection
The system automatically detects the active tab by comparing:- The current URL path
- Query parameters
admin.py
Using Callbacks for Links
Generate links dynamically using thelink_callback option:
admin.py
Use
link_callback when you need to generate links dynamically based on the request object.Combining with Sidebar Navigation
Model tabs work alongside sidebar navigation. When a sidebar link is active, the system checks if any associated model tabs should also be highlighted:admin.py
Permissions
Filter tabs based on user permissions:admin.py
Best Practices
Use meaningful tab titles
Use meaningful tab titles
Choose clear, action-oriented titles that describe what users will see.
Keep query parameters consistent
Keep query parameters consistent
Use consistent query parameter names across your tabs for better maintainability.
Limit the number of tabs
Limit the number of tabs
Too many tabs can overwhelm users. Consider grouping or using a different navigation pattern if you need more than 6-7 tabs.
Consider mobile users
Consider mobile users
Tab navigation adapts to smaller screens, but test your tab configuration on mobile devices to ensure a good experience.
Technical Details
Model tabs are processed through:unfold.sites.UnfoldAdminSite.get_tabs_list()- Returns tab configurationunfold.sites.UnfoldAdminSite._get_is_tab_active()- Determines active tabunfold.templatetags.unfold.tab_list- Renders tabs in templates
Related Features
Inline Tabs
Organize related model inlines in tabs
Fieldset Tabs
Create tabs within fieldsets
Sidebar Navigation
Configure the sidebar navigation
Custom Pages
Add custom pages to the admin