Django 管理
- 作者仓库星标 0
- 作者仓库 skills-registry
Django Admin — Nudge
Branding
The admin is branded to match Nudge's zinc-neutral + yellow-accent palette via a custom template:
backend/templates/admin/base_site.html
This template:
- Extends
admin/base.html(NOTadmin/base_site.html— that would loop) - Overrides Django's CSS variables for both light and dark mode
- Sets the "Nudge" logo linking to
/(the app, not/admin/) - Forces white text on dark headers in all theme modes
- Repaints the "save" (default) submit button with the brand yellow (
#fcd34d) so the primary CTA matches the app
Color palette
Mirrors frontend/src/index.css — source of truth lives there. If it changes, update this template too.
| Token | Light | Dark |
|---|---|---|
| Primary (text / bg dark) | #18181b |
#fafafa |
| Primary hover | #27272a |
#e4e4e7 |
| Accent (brand) | #fcd34d |
#fcd34d |
| Body bg | #fafafa |
#0a0a0b |
| Surface | #ffffff |
#18181b |
| Border | #e4e4e7 |
#27272a |
| Link | #09090b |
#fafafa |
| Link hover | #27272a |
#fcd34d |
Django CSS variables to override
The key to theming Django admin is overriding its own CSS custom properties:
--header-bg, --module-bg, --link-fg, --button-bg, --breadcrumbs-bg, etc.
Do this for :root, html[data-theme="light"], html[data-theme="dark"],
and @media (prefers-color-scheme: dark) with :root:not([data-theme="light"]).
Admin access from the PWA
The frontend has an "Admin" button (staff users only) in the Header component.
It works by creating a hidden form that POSTs the JWT token to /api/auth/admin-access/.
The backend view (apps.users.views.admin_access):
- Is
@csrf_exempt(no CSRF token available from the SPA) - Validates the JWT, checks
is_staff - Creates a Django session via
django_login() - Redirects to
/admin/
i18n
Django admin is multilingual out of the box. We enabled it by:
- Adding
django.middleware.locale.LocaleMiddlewaretoMIDDLEWARE(afterSessionMiddleware, beforeCommonMiddleware) - Setting
LANGUAGES = [("en", "English"), ("es", "Español"), ("gl", "Galego")]
The admin auto-detects language from the browser's Accept-Language header.
Registering models
Pattern used in apps/users/admin.py:
@admin.register(User)
class UserAdmin(BaseUserAdmin):
fieldsets = BaseUserAdmin.fieldsets + (
("Nudge settings", {"fields": ("timezone", "daily_notification_time", "language")}),
)
list_display = ["username", "email", "timezone", "is_staff", "is_active"]
list_filter = ["is_staff", "is_active", "timezone"]
search_fields = ["username", "email"]
<!-- tomevault:4.0:skill_md:2026-05-22 -->Source: cibrandocampo/nudge — distributed by TomeVault.
- 流狐分类
- 设计与多媒体
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 The admin is branded to match Nudge's zinc-neutral + yellow-accent palette via a custom template: backend/templates/admin/basesite.html This template:
Mirrors frontend/src/index.css — source of truth lives there. If it changes, update this template too. Token · Light · Dark Primary (text / bg dark) · 18181b · fafafa
The key to theming Django admin is overriding its own CSS custom properties: --header-bg, --module-bg, --link-fg, --button-bg, --breadcrumbs-bg, etc. Do this for :root, html[data-theme="light"], html[data-theme="dark"],
The frontend has an "Admin" button (staff users only) in the Header component. It works by creating a hidden form that POSTs the JWT token to /api/auth/admin-access/. The backend view (apps.users.views.adminaccess):
Django admin is multilingual out of the box. We enabled it by: Adding django.middleware.locale.LocaleMiddleware to MIDDLEWARE (after SessionMiddleware, before CommonMiddleware)
Pattern used in apps/users/admin.py: Source: cibrandocampo/nudge — distributed by TomeVault. <!-- tomevault:4.0:skillmd:2026-05-22 -->
# Django Admin — Nudge
## Branding
The admin is branded to match Nudge's zinc-neutral + yellow-accent palette via a custom template:
`backend/templates/admin/base_site.html`
This template:
- Extends `admin/base.html` (NOT `admin/base_site.html` — that would loop)
- Overrides Django's CSS variables for both light and dark mode
- Sets the "Nudge" logo linking to `/` (the app, not `/admin/`)
- Forces white text on dark headers in all theme modes
- Repaints the "save" (default) submit button with the brand yellow (`#fcd34d`) so the primary CTA matches the app
### Color palette
Mirrors `frontend/src/index.css` — **source of truth lives there**. If it changes, update this template too.
| Token | Light | Dark |
|-----------------|------------|------------|
| Primary (text / bg dark) | `#18181b` | `#fafafa` |
| Primary hover | `#27272a` | `#e4e4e7` |
| Accent (brand) | `#fcd34d` | `#fcd34d` |
| Body bg | `#fafafa` | `#0a0a0b` |
| Surface | `#ffffff` | `#18181b` |
| Border | `#e4e4e7` | `#27272a` |
| Link | `#09090b` | `#fafafa` |
| Link hover | `#27272a` | `#fcd34d` |
### Django CSS variables to override
The key to theming Django admin is overriding its own CSS custom properties:
`--header-bg`, `--module-bg`, `--link-fg`, `--button-bg`, `--breadcrumbs-bg`, etc.
Do this for `:root`, `html[data-theme="light"]`, `html[data-theme="dark"]`,
and `@media (prefers-color-scheme: dark)` with `:root:not([data-theme="light"])`.
## Admin access from the PWA
The frontend has an "Admin" button (staff users only) in the Header component.
It works by creating a hidden form that POSTs the JWT token to `/api/auth/admin-access/`.
The backend view (`apps.users.views.admin_access`):
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Branding → Color palette → Django CSS variables to override → Admin access from the PWA → i18n → Registering models
要点 -> source of truth lives there · Mirrors frontend/src/index.css — source of truth lives there. · The frontend has an "Admin" button (staff users only) in the Header component. · Django admin is multilingual out of the box. · The admin auto-detects language from the browser's Accept-Language header. · --- > Source: [cibrandocampo/nudge](https://github.com/cibrandocampo/nudge) — distributed by [TomeVault](https://tomevault.io).
文件/命令 -> backend/templates/admin/basesite.html · admin/base.html · admin/basesite.html · (the app, not · #fcd34d · frontend/src/index.css · #18181b · #fafafa
内容 SHA-256 -> b816874a291c
原文结构
适用与边界
原文中的明确线索
backend/templates/admin/basesite.html、admin/base.html、admin/basesite.html、(the app, not、#fcd34d、frontend/src/index.css、#18181b、#fafafa