You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to configure and customize tab navigation in Django Unfold admin changeform views, including model-specific tabs and permission-based access control.
5
+
---
6
+
7
+
# Changeform tabs
8
+
9
+
In changeform view, it is possible to add custom tab navigation. It can consist from various custom links which can point at another registered admin models. The configuration is done in `UNFOLD` dictionary in `settings.py`.
10
+
11
+
Actually, the changeform tab navigation configuration is the same as the changelist tab navigation configuration. The only difference is that in `models` section it is required to specify model name as dictionary with `detail` key set to `True`.
12
+
13
+
```python
14
+
# settings.py
15
+
16
+
from django.urls import reverse_lazy
17
+
from django.utils.translation import gettext_lazy as _
18
+
19
+
UNFOLD= {
20
+
"TABS": [
21
+
{
22
+
# Which changeform models are going to display tab navigation
23
+
"models": [
24
+
{
25
+
"app_label.model_name_in_lowercase",
26
+
"detail": True, # Displays tab navigation on changeform page
Copy file name to clipboardExpand all lines: docs/tabs/changelist.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
---
2
-
title: Changelist
2
+
title: Changelist tabs
3
3
order: 1
4
-
description: Tab navigation in changelist view.
4
+
description: Learn how to configure and customize tab navigation in Django Unfold admin changelist views, including model-specific tabs and permission-based access control.
5
5
---
6
6
7
7
# Changelist tabs
8
+
8
9
In changelist view, it is possible to add custom tab navigation. It can consist from various custom links which can point at another registered admin models. The configuration is done in `UNFOLD` dictionary in `settings.py`.
description: Learn how to dynamically generate tab navigation in Django Unfold admin using custom callbacks and render tabs in custom templates.
5
+
---
6
+
7
+
# Dynamic tabs
8
+
9
+
Unfold provides a way to dynamically generate tab navigation. It is possible to use your own logic to generate tab navigation. The tab navigation configuration can be defined as importable string which will call a function with `HttpRequest` object as an argument. In this function it is possible to build own tabs navigation structure.
10
+
11
+
```python
12
+
# settings.py
13
+
14
+
UNFOLD= {
15
+
"TABS": "your_project.admin.tabs_callback"
16
+
}
17
+
```
18
+
19
+
Below is an example of how to build own tabs navigation structure in tabs callback function. Based on the request object it is possible to write own logic for the tab navigation structure.
Unfold provides a `tab_list` template tag which can be used to render tabs in custom templates. The only required argument is the `page` name which is defined in `TABS` structure on particular tab navigation. Configure `page` key to something unique and then use `tab_list` template tag in your custom template where the first parameter is the unique `page` name.
Below is an example of how to render tabs in custom templates. It is important to load `unfold` template tags before using `tab_list` template tag.
76
+
77
+
```html
78
+
{% extends "admin/base_site.html" %}
79
+
80
+
{% load unfold %}
81
+
82
+
{% block content %}
83
+
{% tab_list "custom_page" %}
84
+
{% endblock %}
85
+
```
86
+
87
+
**Note:** When it comes which tab item is active on custom page, it is not up to Unfold to find out a way how to mark links as active. The tab configuration provides `is_active` key which you can use to set active tab item.
Copy file name to clipboardExpand all lines: docs/tabs/fieldsets.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Fieldsets
3
-
order: 2
4
-
description: Fieldsets with tab navigation.
2
+
title: Fieldsets tabs
3
+
order: 3
4
+
description: Learn how to organize Django admin fieldsets into tabs for better form organization and user experience by using CSS classes to group related fields into tabbed navigation.
Copy file name to clipboardExpand all lines: docs/tabs/inline.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Inlines
3
-
order: 3
4
-
description: Change form tab navigation from inlines.
2
+
title: Inlines tabs
3
+
order: 4
4
+
description: Learn how to organize Django admin inlines into tabs by using the tab attribute in inline classes, enabling better form organization and user experience in changeform views.
0 commit comments