unfold-admin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Django Unfold Admin

Django Unfold 管理后台

Modern Django admin theme with Tailwind CSS, HTMX, and Alpine.js. Replaces Django's default admin with a polished, feature-rich interface.
基于Tailwind CSS、HTMX和Alpine.js的现代化Django admin主题,以精致且功能丰富的界面替代Django默认的管理后台。

Quick Start

快速开始

Installation

安装

python
undefined
python
undefined

settings.py - unfold MUST be before django.contrib.admin

settings.py - unfold MUST be before django.contrib.admin

INSTALLED_APPS = [ "unfold", "unfold.contrib.filters", # advanced filters "unfold.contrib.forms", # array/wysiwyg widgets "unfold.contrib.inlines", # nonrelated inlines "unfold.contrib.import_export", # styled import/export "unfold.contrib.guardian", # django-guardian integration "unfold.contrib.simple_history", # django-simple-history integration "unfold.contrib.constance", # django-constance integration "unfold.contrib.location_field", # django-location-field integration # ... "django.contrib.admin", ]
undefined
INSTALLED_APPS = [ "unfold", "unfold.contrib.filters", # advanced filters "unfold.contrib.forms", # array/wysiwyg widgets "unfold.contrib.inlines", # nonrelated inlines "unfold.contrib.import_export", # styled import/export "unfold.contrib.guardian", # django-guardian integration "unfold.contrib.simple_history", # django-simple-history integration "unfold.contrib.constance", # django-constance integration "unfold.contrib.location_field", # django-location-field integration # ... "django.contrib.admin", ]
undefined

Minimal Admin

最简管理后台配置

python
from unfold.admin import ModelAdmin

@admin.register(MyModel)
class MyModelAdmin(ModelAdmin):
    pass  # inherits Unfold styling
python
from unfold.admin import ModelAdmin

@admin.register(MyModel)
class MyModelAdmin(ModelAdmin):
    pass  # inherits Unfold styling

Site Configuration

站点配置

Replace the default
AdminSite
or configure via
UNFOLD
dict in settings. See references/configuration.md for the complete settings reference.
python
UNFOLD = {
    "SITE_TITLE": "My Admin",
    "SITE_HEADER": "My Admin",
    "SITE_SYMBOL": "dashboard",  # Material Symbols icon name
    "SIDEBAR": {
        "show_search": True,
        "navigation": [
            {
                "title": _("Navigation"),
                "items": [
                    {
                        "title": _("Dashboard"),
                        "icon": "dashboard",
                        "link": reverse_lazy("admin:index"),
                    },
                ],
            },
        ],
    },
}
替换默认的
AdminSite
或通过settings中的
UNFOLD
字典进行配置。完整设置参考请查看references/configuration.md
python
UNFOLD = {
    "SITE_TITLE": "My Admin",
    "SITE_HEADER": "My Admin",
    "SITE_SYMBOL": "dashboard",  # Material Symbols icon name
    "SIDEBAR": {
        "show_search": True,
        "navigation": [
            {
                "title": _("Navigation"),
                "items": [
                    {
                        "title": _("Dashboard"),
                        "icon": "dashboard",
                        "link": reverse_lazy("admin:index"),
                    },
                ],
            },
        ],
    },
}

Core Workflow

核心工作流程

When building Unfold admin interfaces, follow this sequence:
  1. Configure site - UNFOLD settings dict (branding, sidebar, theme)
  2. Register models - Extend
    unfold.admin.ModelAdmin
  3. Enhance display -
    @display
    decorator for list columns
  4. Add actions -
    @action
    decorator for row/list/detail/submit actions
  5. Configure filters - Replace default filters with Unfold filter classes
  6. Override widgets - Apply Unfold widgets via
    formfield_overrides
  7. Set up inlines - Use Unfold's inline classes with tabs, pagination, sorting
  8. Build dashboard -
    @register_component
    +
    BaseComponent
    for KPI cards
构建Unfold管理界面时,请遵循以下步骤:
  1. 配置站点 - 使用UNFOLD设置字典(品牌、侧边栏、主题)
  2. 注册模型 - 继承
    unfold.admin.ModelAdmin
  3. 增强显示效果 - 使用
    @display
    装饰器优化列表列
  4. 添加操作 - 使用
    @action
    装饰器实现列表行/列表/详情/提交区域操作
  5. 配置过滤器 - 用Unfilter过滤器类替换默认过滤器
  6. 重写小部件 - 通过
    formfield_overrides
    应用Unfold小部件
  7. 设置内联组件 - 使用Unfold的内联类实现标签页、分页、排序功能
  8. 构建仪表盘 - 结合
    @register_component
    BaseComponent
    创建KPI卡片

ModelAdmin Attributes

ModelAdmin扩展属性

Unfold extends Django's
ModelAdmin
with these additional attributes:
AttributeTypePurpose
list_fullwidth
boolFull-width changelist (no sidebar)
list_filter_submit
boolAdd submit button to filters
list_filter_sheet
boolFilters in sliding sheet panel
compressed_fields
boolCompact field spacing in forms
warn_unsaved_form
boolWarn before leaving unsaved form
ordering_field
strField name for drag-to-reorder
hide_ordering_field
boolHide the ordering field column
list_horizontal_scrollbar_top
boolScrollbar at top of list
list_disable_select_all
boolDisable "select all" checkbox
change_form_show_cancel_button
boolShow cancel button on form
actions_list
listGlobal changelist actions
actions_row
listPer-row actions in changelist
actions_detail
listActions on change form
actions_submit_line
listActions in form submit area
actions_list_hide_default
boolHide default list actions
actions_detail_hide_default
boolHide default detail actions
conditional_fields
dictJS expressions for field visibility
change_form_datasets
listBaseDataset subclasses for change form
list_sections
listTableSection/TemplateSection for list
list_sections_classes
strCSS grid classes for sections
readonly_preprocess_fields
dictTransform readonly field content
add_fieldsets
listSeparate fieldsets for add form (like UserAdmin)
Unfold为Django的
ModelAdmin
扩展了以下额外属性:
属性类型用途
list_fullwidth
bool列表页全屏显示(无侧边栏)
list_filter_submit
bool为过滤器添加提交按钮
list_filter_sheet
bool在滑动面板中显示过滤器
compressed_fields
bool表单中字段间距紧凑显示
warn_unsaved_form
bool未保存表单时离开页面发出警告
ordering_field
str用于拖拽排序的字段名
hide_ordering_field
bool隐藏排序字段列
list_horizontal_scrollbar_top
bool列表顶部显示横向滚动条
list_disable_select_all
bool禁用"全选"复选框
change_form_show_cancel_button
bool在表单中显示取消按钮
actions_list
list全局列表页操作
actions_row
list列表页每行操作
actions_detail
list详情页操作
actions_submit_line
list表单提交区域操作
actions_list_hide_default
bool隐藏默认列表操作
actions_detail_hide_default
bool隐藏默认详情操作
conditional_fields
dict控制字段可见性的JS表达式
change_form_datasets
list详情页使用的BaseDataset子类
list_sections
list列表页使用的TableSection/TemplateSection
list_sections_classes
str分区的CSS网格类
readonly_preprocess_fields
dict转换只读字段内容
add_fieldsets
list新增表单的独立字段集(类似UserAdmin)

Template Injection Points

模板注入点

Insert custom HTML before/after changelist or change form:
python
class MyAdmin(ModelAdmin):
    # Changelist
    list_before_template = "myapp/list_before.html"
    list_after_template = "myapp/list_after.html"
    # Change form (inside <form> tag)
    change_form_before_template = "myapp/form_before.html"
    change_form_after_template = "myapp/form_after.html"
    # Change form (outside <form> tag)
    change_form_outer_before_template = "myapp/outer_before.html"
    change_form_outer_after_template = "myapp/outer_after.html"
在列表页或详情页前后插入自定义HTML:
python
class MyAdmin(ModelAdmin):
    # 列表页
    list_before_template = "myapp/list_before.html"
    list_after_template = "myapp/list_after.html"
    # 详情页(<form>标签内)
    change_form_before_template = "myapp/form_before.html"
    change_form_after_template = "myapp/form_after.html"
    # 详情页(<form>标签外)
    change_form_outer_before_template = "myapp/outer_before.html"
    change_form_outer_after_template = "myapp/outer_after.html"

Conditional Fields

条件字段

Show/hide fields based on other field values (Alpine.js expressions):
python
class MyAdmin(ModelAdmin):
    conditional_fields = {
        "premium_features": "plan == 'PRO'",
        "discount_amount": "has_discount == true",
    }
基于其他字段值显示/隐藏字段(使用Alpine.js表达式):
python
class MyAdmin(ModelAdmin):
    conditional_fields = {
        "premium_features": "plan == 'PRO'",
        "discount_amount": "has_discount == true",
    }

Actions System

操作系统

Four action types, each with different signatures. See references/actions-filters.md for complete reference.
python
from unfold.decorators import action
from unfold.enums import ActionVariant
支持四种操作类型,每种类型有不同的签名。完整参考请查看references/actions-filters.md
python
from unfold.decorators import action
from unfold.enums import ActionVariant

List action (no object context)

列表操作(无对象上下文)

@action(description=_("Rebuild Index"), icon="sync", variant=ActionVariant.PRIMARY) def rebuild_index(self, request): # process... return redirect(request.headers["referer"])
@action(description=_("Rebuild Index"), icon="sync", variant=ActionVariant.PRIMARY) def rebuild_index(self, request): # process... return redirect(request.headers["referer"])

Row action (receives object_id)

行操作(接收object_id)

@action(description=_("Approve"), url_path="approve") def approve_row(self, request, object_id): obj = self.model.objects.get(pk=object_id) return redirect(request.headers["referer"])
@action(description=_("Approve"), url_path="approve") def approve_row(self, request, object_id): obj = self.model.objects.get(pk=object_id) return redirect(request.headers["referer"])

Detail action (receives object_id, shown on change form)

详情操作(接收object_id,显示在详情页)

@action(description=_("Send Email"), permissions=["send_email"]) def send_email(self, request, object_id): return redirect(reverse_lazy("admin:myapp_mymodel_change", args=[object_id]))
@action(description=_("Send Email"), permissions=["send_email"]) def send_email(self, request, object_id): return redirect(reverse_lazy("admin:myapp_mymodel_change", args=[object_id]))

Submit line action (receives obj instance, runs on save)

提交区域操作(接收obj实例,保存时执行)

@action(description=_("Save & Publish")) def save_and_publish(self, request, obj): obj.published = True
undefined
@action(description=_("Save & Publish")) def save_and_publish(self, request, obj): obj.published = True
undefined

Action Groups (Dropdown Menus)

操作组(下拉菜单)

python
actions_list = [
    "primary_action",
    {
        "title": _("More"),
        "variant": ActionVariant.PRIMARY,
        "items": ["secondary_action", "tertiary_action"],
    },
]
python
actions_list = [
    "primary_action",
    {
        "title": _("More"),
        "variant": ActionVariant.PRIMARY,
        "items": ["secondary_action", "tertiary_action"],
    },
]

Permissions

权限控制

python
@action(permissions=["can_export", "auth.view_user"])
def export_data(self, request):
    pass

def has_can_export_permission(self, request):
    return request.user.is_superuser
python
@action(permissions=["can_export", "auth.view_user"])
def export_data(self, request):
    pass

def has_can_export_permission(self, request):
    return request.user.is_superuser

Display Decorator

显示装饰器

Enhance list_display columns. See references/actions-filters.md.
python
from unfold.decorators import display
增强list_display列的显示效果。参考references/actions-filters.md
python
from unfold.decorators import display

Colored status labels

带颜色的状态标签

@display(description=_("Status"), ordering="status", label={ "active": "success", # green "pending": "info", # blue "warning": "warning", # orange "inactive": "danger", # red }) def show_status(self, obj): return obj.status
@display(description=_("Status"), ordering="status", label={ "active": "success", # green "pending": "info", # blue "warning": "warning", # orange "inactive": "danger", # red }) def show_status(self, obj): return obj.status

Rich header with avatar

带头像的富文本头部

@display(description=_("User"), header=True) def show_header(self, obj): return [ obj.full_name, # primary text obj.email, # secondary text obj.initials, # badge text {"path": obj.avatar.url, "width": 24, "height": 24, "borderless": True}, ]
@display(description=_("User"), header=True) def show_header(self, obj): return [ obj.full_name, # primary text obj.email, # secondary text obj.initials, # badge text {"path": obj.avatar.url, "width": 24, "height": 24, "borderless": True}, ]

Interactive dropdown

交互式下拉菜单

@display(description=_("Teams"), dropdown=True) def show_teams(self, obj): return { "title": f"{obj.teams.count()} teams", "items": [{"title": t.name, "link": t.get_admin_url()} for t in obj.teams.all()], "striped": True, "max_height": 200, }
@display(description=_("Teams"), dropdown=True) def show_teams(self, obj): return { "title": f"{obj.teams.count()} teams", "items": [{"title": t.name, "link": t.get_admin_url()} for t in obj.teams.all()], "striped": True, "max_height": 200, }

Boolean checkmark

布尔值勾选框

@display(description=_("Active"), boolean=True) def is_active(self, obj): return obj.is_active
undefined
@display(description=_("Active"), boolean=True) def is_active(self, obj): return obj.is_active
undefined

Filters

过滤器

Unfold provides advanced filter classes. See references/actions-filters.md.
python
from unfold.contrib.filters.admin import (
    TextFilter, RangeNumericFilter, RangeDateFilter, RangeDateTimeFilter,
    SingleNumericFilter, SliderNumericFilter, RelatedDropdownFilter,
    RelatedCheckboxFilter, ChoicesCheckboxFilter, AllValuesCheckboxFilter,
    BooleanRadioFilter, CheckboxFilter, AutocompleteSelectMultipleFilter,
)

class MyAdmin(ModelAdmin):
    list_filter_submit = True  # required for input-based filters
    list_filter = [
        ("salary", RangeNumericFilter),
        ("status", ChoicesCheckboxFilter),
        ("created_at", RangeDateFilter),
        ("category", RelatedDropdownFilter),
        ("is_active", BooleanRadioFilter),
    ]
Unfold提供高级过滤器类。参考references/actions-filters.md
python
from unfold.contrib.filters.admin import (
    TextFilter, RangeNumericFilter, RangeDateFilter, RangeDateTimeFilter,
    SingleNumericFilter, SliderNumericFilter, RelatedDropdownFilter,
    RelatedCheckboxFilter, ChoicesCheckboxFilter, AllValuesCheckboxFilter,
    BooleanRadioFilter, CheckboxFilter, AutocompleteSelectMultipleFilter,
)

class MyAdmin(ModelAdmin):
    list_filter_submit = True  # required for input-based filters
    list_filter = [
        ("salary", RangeNumericFilter),
        ("status", ChoicesCheckboxFilter),
        ("created_at", RangeDateFilter),
        ("category", RelatedDropdownFilter),
        ("is_active", BooleanRadioFilter),
    ]

Custom Text Filter

自定义文本过滤器

python
class NameFilter(TextFilter):
    title = _("Name")
    parameter_name = "name"

    def queryset(self, request, queryset):
        if self.value() in EMPTY_VALUES:
            return queryset
        return queryset.filter(name__icontains=self.value())
python
class NameFilter(TextFilter):
    title = _("Name")
    parameter_name = "name"

    def queryset(self, request, queryset):
        if self.value() in EMPTY_VALUES:
            return queryset
        return queryset.filter(name__icontains=self.value())

Widgets

小部件

Override form widgets for Unfold styling. See references/widgets-inlines.md.
python
from unfold.widgets import (
    UnfoldAdminTextInputWidget, UnfoldAdminSelectWidget, UnfoldAdminSelect2Widget,
    UnfoldBooleanSwitchWidget, UnfoldAdminColorInputWidget,
    UnfoldAdminSplitDateTimeWidget, UnfoldAdminImageFieldWidget,
)
from unfold.contrib.forms.widgets import WysiwygWidget, ArrayWidget

class MyAdmin(ModelAdmin):
    formfield_overrides = {
        models.TextField: {"widget": WysiwygWidget},
        models.ImageField: {"widget": UnfoldAdminImageFieldWidget},
    }
重写表单小部件以应用Unfold样式。参考references/widgets-inlines.md
python
from unfold.widgets import (
    UnfoldAdminTextInputWidget, UnfoldAdminSelectWidget, UnfoldAdminSelect2Widget,
    UnfoldBooleanSwitchWidget, UnfoldAdminColorInputWidget,
    UnfoldAdminSplitDateTimeWidget, UnfoldAdminImageFieldWidget,
)
from unfold.contrib.forms.widgets import WysiwygWidget, ArrayWidget

class MyAdmin(ModelAdmin):
    formfield_overrides = {
        models.TextField: {"widget": WysiwygWidget},
        models.ImageField: {"widget": UnfoldAdminImageFieldWidget},
    }

Text Input with Icons

带图标的文本输入框

python
widget = UnfoldAdminTextInputWidget(attrs={
    "prefix_icon": "search",
    "suffix_icon": "euro",
})
python
widget = UnfoldAdminTextInputWidget(attrs={
    "prefix_icon": "search",
    "suffix_icon": "euro",
})

Inlines

内联组件

Unfold inlines support tabs, pagination, sorting, and nonrelated models. See references/widgets-inlines.md.
python
from unfold.admin import TabularInline, StackedInline
from unfold.contrib.inlines.admin import NonrelatedStackedInline

class OrderItemInline(TabularInline):
    model = OrderItem
    tab = True          # show as tab
    per_page = 10       # paginated
    ordering_field = "weight"  # drag-to-reorder
    hide_title = True
    collapsible = True
Unfold内联组件支持标签页、分页、排序和非关联模型。参考references/widgets-inlines.md
python
from unfold.admin import TabularInline, StackedInline
from unfold.contrib.inlines.admin import NonrelatedStackedInline

class OrderItemInline(TabularInline):
    model = OrderItem
    tab = True          # show as tab
    per_page = 10       # paginated
    ordering_field = "weight"  # drag-to-reorder
    hide_title = True
    collapsible = True

Fieldset Tabs

字段集标签页

Group fieldsets into tabs using
"classes": ["tab"]
:
python
fieldsets = [
    (None, {"fields": ["name", "email"]}),  # always visible
    (_("Profile"), {"classes": ["tab"], "fields": ["bio", "avatar"]}),
    (_("Settings"), {"classes": ["tab"], "fields": ["theme", "notifications"]}),
]
使用
"classes": ["tab"]
将字段组分组成标签页:
python
fieldsets = [
    (None, {"fields": ["name", "email"]}),  # always visible
    (_("Profile"), {"classes": ["tab"], "fields": ["bio", "avatar"]}),
    (_("Settings"), {"classes": ["tab"], "fields": ["theme", "notifications"]}),
]

Dashboard Components

仪表盘组件

Build KPI cards and custom dashboard widgets. See references/dashboard.md.
python
from unfold.components import BaseComponent, register_component
from django.template.loader import render_to_string

@register_component
class ActiveUsersComponent(BaseComponent):
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["children"] = render_to_string("myapp/kpi_card.html", {
            "total": User.objects.filter(is_active=True).count(),
            "label": "Active Users",
        })
        return context
Configure in settings:
python
UNFOLD = {
    "DASHBOARD_CALLBACK": "myapp.views.dashboard_callback",
}
构建KPI卡片和自定义仪表盘小部件。参考references/dashboard.md
python
from unfold.components import BaseComponent, register_component
from django.template.loader import render_to_string

@register_component
class ActiveUsersComponent(BaseComponent):
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["children"] = render_to_string("myapp/kpi_card.html", {
            "total": User.objects.filter(is_active=True).count(),
            "label": "Active Users",
        })
        return context
在settings中配置:
python
UNFOLD = {
    "DASHBOARD_CALLBACK": "myapp.views.dashboard_callback",
}

Sections (Changelist Panels)

分区(列表页面板)

Embed related data panels in changelist views:
python
from unfold.sections import TableSection, TemplateSection

class RecentOrdersSection(TableSection):
    related_name = "order_set"
    fields = ["id", "total", "status"]
    height = 380

class ChartSection(TemplateSection):
    template_name = "myapp/chart.html"

class MyAdmin(ModelAdmin):
    list_sections = [RecentOrdersSection, ChartSection]
    list_sections_classes = "lg:grid-cols-2"
在列表页中嵌入关联数据面板:
python
from unfold.sections import TableSection, TemplateSection

class RecentOrdersSection(TableSection):
    related_name = "order_set"
    fields = ["id", "total", "status"]
    height = 380

class ChartSection(TemplateSection):
    template_name = "myapp/chart.html"

class MyAdmin(ModelAdmin):
    list_sections = [RecentOrdersSection, ChartSection]
    list_sections_classes = "lg:grid-cols-2"

Datasets (Change Form Panels)

数据集(详情页面板)

Embed model listings within change forms:
python
from unfold.datasets import BaseDataset

class RelatedItemsDatasetAdmin(ModelAdmin):
    list_display = ["name", "status"]
    search_fields = ["name"]

class RelatedItemsDataset(BaseDataset):
    model = RelatedItem
    model_admin = RelatedItemsDatasetAdmin
    tab = True  # show as tab

class MyAdmin(ModelAdmin):
    change_form_datasets = [RelatedItemsDataset]
在详情页中嵌入模型列表:
python
from unfold.datasets import BaseDataset

class RelatedItemsDatasetAdmin(ModelAdmin):
    list_display = ["name", "status"]
    search_fields = ["name"]

class RelatedItemsDataset(BaseDataset):
    model = RelatedItem
    model_admin = RelatedItemsDatasetAdmin
    tab = True  # show as tab

class MyAdmin(ModelAdmin):
    change_form_datasets = [RelatedItemsDataset]

Paginator

分页器

Use infinite scroll pagination:
python
from unfold.paginator import InfinitePaginator

class MyAdmin(ModelAdmin):
    paginator = InfinitePaginator
    show_full_result_count = False
    list_per_page = 20
使用无限滚动分页:
python
from unfold.paginator import InfinitePaginator

class MyAdmin(ModelAdmin):
    paginator = InfinitePaginator
    show_full_result_count = False
    list_per_page = 20

Third-Party Integrations

第三方集成

Unfold provides styled wrappers for common Django packages. See references/resources.md for complete setup guides.
PackageUnfold ModuleSetup
django-import-export
unfold.contrib.import_export
Use
ImportForm
,
ExportForm
,
SelectableFieldsExportForm
django-guardian
unfold.contrib.guardian
Styled guardian integration
django-simple-history
unfold.contrib.simple_history
Styled history integration
django-constance
unfold.contrib.constance
Styled constance config
django-location-field
unfold.contrib.location_field
Location widget
django-modeltranslationCompatibleMix
TabbedTranslationAdmin
with
ModelAdmin
django-celery-beatCompatible (rewire)Unregister 5 models, re-register with Unfold
django-money
unfold.widgets
UnfoldAdminMoneyWidget
djangoqlCompatibleMix
DjangoQLSearchMixin
with
ModelAdmin
django-crispy-formsCompatibleUnfold template pack available
python
undefined
Unfold为常见Django包提供样式化封装。完整设置指南请参考references/resources.md
Unfold模块设置方式
django-import-export
unfold.contrib.import_export
使用
ImportForm
,
ExportForm
,
SelectableFieldsExportForm
django-guardian
unfold.contrib.guardian
样式化的guardian集成
django-simple-history
unfold.contrib.simple_history
样式化的历史记录集成
django-constance
unfold.contrib.constance
样式化的constance配置
django-location-field
unfold.contrib.location_field
位置选择小部件
django-modeltranslation兼容
TabbedTranslationAdmin
ModelAdmin
混合使用
django-celery-beat兼容(需重新注册)注销5个模型,使用Unfold重新注册
django-money
unfold.widgets
UnfoldAdminMoneyWidget
djangoql兼容
DjangoQLSearchMixin
ModelAdmin
混合使用
django-crispy-forms兼容提供Unfold模板包
python
undefined

Multiple inheritance - Unfold ModelAdmin always last

多重继承 - Unfold ModelAdmin必须放在最后

@admin.register(MyModel) class MyAdmin(DjangoQLSearchMixin, SimpleHistoryAdmin, GuardedModelAdmin, ModelAdmin): pass
undefined
@admin.register(MyModel) class MyAdmin(DjangoQLSearchMixin, SimpleHistoryAdmin, GuardedModelAdmin, ModelAdmin): pass
undefined

Built-In Template Components

内置模板组件

Unfold ships reusable template components for dashboards and custom pages:
ComponentPathKey Variables
Card
unfold/components/card.html
title
,
footer
,
label
,
icon
Bar Chart
unfold/components/chart/bar.html
data
(JSON),
height
,
width
Line Chart
unfold/components/chart/line.html
data
(JSON),
height
,
width
Progress
unfold/components/progress.html
value
,
title
,
description
Table
unfold/components/table.html
table
,
card_included
,
striped
Button
unfold/components/button.html
name
,
href
,
submit
Tracker
unfold/components/tracker.html
data
Cohort
unfold/components/cohort.html
data
html
{% load unfold %}
{% component "MyKPIComponent" %}{% endcomponent %}
Unfold提供可复用的模板组件,用于仪表盘和自定义页面:
组件路径关键变量
卡片
unfold/components/card.html
title
,
footer
,
label
,
icon
柱状图
unfold/components/chart/bar.html
data
(JSON格式),
height
,
width
折线图
unfold/components/chart/line.html
data
(JSON格式),
height
,
width
进度条
unfold/components/progress.html
value
,
title
,
description
表格
unfold/components/table.html
table
,
card_included
,
striped
按钮
unfold/components/button.html
name
,
href
,
submit
追踪器
unfold/components/tracker.html
data
同期群分析
unfold/components/cohort.html
data
html
{% load unfold %}
{% component "MyKPIComponent" %}{% endcomponent %}

User Admin Forms

用户管理后台表单

Unfold provides styled versions of Django's auth admin forms:
python
from unfold.forms import AdminPasswordChangeForm, UserChangeForm, UserCreationForm

@admin.register(User)
class UserAdmin(BaseUserAdmin, ModelAdmin):
    form = UserChangeForm
    add_form = UserCreationForm
    change_password_form = AdminPasswordChangeForm
Unfold提供Django auth管理表单的样式化版本:
python
from unfold.forms import AdminPasswordChangeForm, UserChangeForm, UserCreationForm

@admin.register(User)
class UserAdmin(BaseUserAdmin, ModelAdmin):
    form = UserChangeForm
    add_form = UserCreationForm
    change_password_form = AdminPasswordChangeForm

Reference Files

参考文档

Detailed documentation split by topic:
  • references/configuration.md - Complete UNFOLD settings dict, sidebar, tabs, theming, environment, login
  • references/actions-filters.md - Action types and signatures, display decorator, all filter classes
  • references/widgets-inlines.md - Complete widget class list (35+), inline variants, nonrelated inlines, forms
  • references/dashboard.md - Dashboard components, sections, datasets, custom templates, Tailwind patterns
  • references/resources.md - Official links, all third-party integrations, common patterns, version compatibility, Unfold Studio
Read the relevant reference file when you need detailed configuration options, the full list of available classes, complete code examples, or integration setup guides for a specific feature area.
按主题拆分的详细文档:
  • references/configuration.md - 完整的UNFOLD设置字典、侧边栏、标签页、主题、环境、登录配置
  • references/actions-filters.md - 操作类型和签名、显示装饰器、所有过滤器类
  • references/widgets-inlines.md - 完整的小部件类列表(30+)、内联变体、非关联内联、表单
  • references/dashboard.md - 仪表盘组件、分区、数据集、自定义模板、Tailwind模式
  • references/resources.md - 官方链接、所有第三方集成、常见模式、版本兼容性、Unfold Studio
当需要详细配置选项、完整的可用类列表、完整代码示例或特定功能区域的集成设置指南时,请阅读对应的参考文档。

Key External References

关键外部参考

When uncertain about an implementation pattern, consult
formula/admin.py
and
formula/settings.py
in the Formula demo repo - it covers virtually every Unfold feature.
当不确定实现方式时,请参考Formula演示仓库中的
formula/admin.py
formula/settings.py
——它几乎覆盖了Unfold的所有功能。