aiohttp
免费Use when building Python async HTTP services or clients with aiohttp - web server routing, middleware, WebSocket, SSE, streaming, client sessions, pytest-aiohttp testing, or troubleshooting SSL and timeout issues
中文简介正在准备中。当前显示原文说明。
Use when theming the Django admin with django-unfold - settings and sidebar configuration, custom admin site, components and @display decorator, filters, actions, tabs, dark mode and styling, or Django 6.x compatibility
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Modern Django admin theme with beautiful design and advanced features.
Unfold is a modern theme for Django admin that provides:
Versions: django-unfold 0.76.x + Django 6.0 fully compatible.
pip install django-unfold
# Or with specific version
pip install django-unfold==0.9.0
# settings.py
INSTALLED_APPS = [
'unfold', # Must come BEFORE django.contrib.admin
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
# ... other apps
]
# Unfold settings
UNFOLD = {
# Configuration here
}
Important:
unfoldmust be first inINSTALLED_APPSto override Django templates.
# settings.py
INSTALLED_APPS = [
'unfold',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
]
# Optional: Add your custom admin site class
# UNFOLD_ADMIN_SITE_CLASS = 'path.to.CustomAdminSite'
Unfold doesn't require changes to your URL configuration:
# urls.py - No changes needed!
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
# ... other urls
]
# Install
pip install django-guardian
# Add to INSTALLED_APPS
INSTALLED_APPS = [
'guardian',
'unfold',
'django.contrib.admin',
# ...
]
# Add to URLs
from django.contrib import admin
from unfold.contrib.guardian.admin import GuardedModelAdmin
class ArticleAdmin(GuardedModelAdmin):
pass
pip install django-import-export
# Works automatically with Unfold
# Custom resource if needed
from import_export import resources
from unfold.admin import ImportExportMixin
class ArticleResource(resources.ModelResource):
class Meta:
model = Article
fields = ('id', 'title', 'status', 'created_at')
class ArticleAdmin(ImportExportMixin, ModelAdmin):
resource_classes = [ArticleResource]
# Install
pip install django-celery-beat
# Configuration is automatic with Unfold
# Shows schedule in admin dashboard
pip install django-constance[database]
INSTALLED_APPS = [
'constance',
'unfold',
# ...
]
# Configuration is automatic
# Shows in admin under "Constance" section
When you need this: Customize the admin login page to match your design system using unfold's template overrides.
# settings.py - Override login template
def get_custom_login_template(request):
return "admin/custom_login.html"
UNFOLD = {
'TEMPLATES': {
'login': get_custom_login_template,
},
'LOGIN': {
'show_language_switcher': False,
'extra_fields': [
{'field': 'organization', 'type': 'select', 'required': True},
],
},
}
<!-- templates/admin/custom_login.html -->
{% extends "unfold/login.html" %}
{% load i18n %}
{% block branding %}
<div class="flex items-center gap-3 mb-6">
<img src="/static/img/company-logo.svg" alt="Company" class="h-10">
<span class="text-xl font-semibold">Admin Portal</span>
</div>
{% endblock %}
When you need this: Add custom fields to the user admin form for organization-specific user attributes.
# admin.py
from django.contrib import admin
from unfold.admin import ModelAdmin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from unfold.contrib.filters import AutocompleteFilter
class OrganizationFilter(AutocompleteFilter):
title = "Organization"
field_name = "organization"
@admin.register(User)
class UserAdmin(BaseUserAdmin):
# Inherit Unfold styling while adding custom fields
fieldsets = BaseUserAdmin.fieldsets + (
("Organization", {"fields": ("organization", "employee_id")}),
)
add_fieldsets = BaseUserAdmin.add_fieldsets + (
("Organization", {"fields": ("organization",)}),
)
list_filter = BaseUserAdmin.list_filter + ("organization", OrganizationFilter)
When you need this: Override the entire authentication flow with custom admin site class.
# admin.py
from unfold.admin import UnfoldAdminSite
from django.contrib.auth.forms import AuthenticationForm
class CustomAuthForm(AuthenticationForm):
def confirm_login_allowed(self, user):
# Custom authentication logic
if not user.is_active:
raise ValidationError("Account inactive")
if user.organization.status != "active":
raise ValidationError("Organization suspended")
class CustomAdminSite(UnfoldAdminSite):
def login(self, request, extra_context=None):
extra_context = extra_context or {}
extra_context["custom_message"] = "Welcome to the admin"
return super().login(request, extra_context)
admin_site = CustomAdminSite(name="custom")
# settings.py
UNFOLD_ADMIN_SITE_CLASS = "myapp.admin.CustomAdminSite"
Failure: Unfold silently ignored, admin renders with default Django theme.
# WRONG - unfold must come BEFORE django.contrib.admin
INSTALLED_APPS = [
'django.contrib.admin', # ❌ Too late, templates already loaded
'unfold',
]
# CORRECT
INSTALLED_APPS = [
'unfold', # ✅ Template engine override works
'django.contrib.admin',
]
Failure: Custom template doesn't apply Unfold styling because it extends wrong base.
# WRONG - extends stock Django admin, bypasses Unfold
{% extends "admin/base.html" %} # ❌ Missing Unfold blocks
# CORRECT - extends Unfold's base template
{% extends "unfold/base.html" %} # ✅ Gets Unfold's CSS, layout, sidebar
Failure: Settings silently ignored due to lowercase keys.
# WRONG - keys must be UPPER_CASE
UNFOLD = {
'site_header': 'My Admin', # ❌ Ignored
'show_sidebar': True, # ❌ Ignored
}
# CORRECT
UNFOLD = {
'SITE_HEADER': 'My Admin', # ✅
'SHOW_SIDEBAR': True, # ✅
}
Failure: Custom CSS conflicts with Unfold's Tailwind classes, requires constant maintenance.
# WRONG - raw CSS file overrides Unfold classes
UNFOLD = {
'STYLES': ['css/custom.css'], # ❌ Brittle, breaks on Unfold updates
}
/* custom.css */
.sidebar { background: blue !important; } /* ❌ Fighting framework */
Correct approach: Use Unfold's theme customization or Tailwind config.
# CORRECT - extend Unfold's color system
UNFOLD = {
'COLORS': {
'primary': {
'50': '239 246 255',
'500': '59 130 246',
# ... full palette
},
},
}
Solves: Per-object permissions beyond Django's model-level permissions.
add, change, delete, view) are sufficientURL: https://github.com/django-guardian/django-guardian
Solves: Import/export data via CSV, Excel, YAML in admin.
URL: https://github.com/django-import-export/django-import-export
Solves: Schedule periodic Celery tasks via admin interface.
URL: https://github.com/celery/django-celery-beat
Solves: Runtime site-wide settings editable via admin.
URL: https://github.com/jazzband/django-constance
Solves: Replace admin popup windows with in-page modals for related object selection.
URL: https://github.com/metaforx/django-unfold-modal
Solves: Markdown editor widget for admin text fields.
URL: https://github.com/sergei-vasilev-dev/django-unfold-markdown
Plain Django admin is sufficient when:
Check before adopting:
If answers are "no" to most, stick with stock Django admin or consider lighter themes.
| Unfold Version | Django Version |
|---|---|
| 0.76.x + | 6.0+ |
| 0.70.x - 0.75.x | 5.0+, 5.1+ |
| 0.60.x - 0.69.x | 4.2+, 5.0+ |
| 0.50.x - 0.59.x | 4.1+, 4.2+ |
Full compatibility matrix: https://unfoldadmin.com/docs/installation/#compatibility
For detailed reference, load these on-demand:
references/settings-customization.md - Settings reference, custom admin site, dark mode, custom stylingreferences/components-actions.md - Components, fields, filters, actions, tabsreferences/ecosystem-compat.md - Ecosystem libraries, Django 6.x compatibility, ordering notes还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Use when building Python async HTTP services or clients with aiohttp - web server routing, middleware, WebSocket, SSE, streaming, client sessions, pytest-aiohttp testing, or troubleshooting SSL and timeout issues
中文简介正在准备中。当前显示原文说明。
Use when doing structural code search and rewriting - ast-grep linting, refactoring, multi-language patterns
中文简介正在准备中。当前显示原文说明。
Use when building GBA games with the BPCore Lua engine - entity, sprite and tilemap functions, SRAM save and load, link cable multiplayer protocol, camera and scrolling, or optimization patterns
中文简介正在准备中。当前显示原文说明。
Use when running background tasks with Celery - worker and broker configuration (Redis, RabbitMQ), task routing by name vs queue, chains/groups/chords, retry patterns (autoretry_for, retry_backoff), acks_late semantics, failure detection, and monitoring with Flower
中文简介正在准备中。当前显示原文说明。
Use when building Django applications - security hardening, authentication and permissions, ORM optimization, PostgreSQL features, Django 6.0, migrations, testing, and ecosystem libraries
中文简介正在准备中。当前显示原文说明。
Use when customizing Django Admin - save_formset, get_search_results, formsets, queryset optimization, db_index, custom URLs
中文简介正在准备中。当前显示原文说明。