django-eadmin 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. django_eadmin-0.1.0/MANIFEST.in +4 -0
  2. django_eadmin-0.1.0/PKG-INFO +84 -0
  3. django_eadmin-0.1.0/README-eadmin.md +68 -0
  4. django_eadmin-0.1.0/README.md +189 -0
  5. django_eadmin-0.1.0/django_eadmin.egg-info/PKG-INFO +84 -0
  6. django_eadmin-0.1.0/django_eadmin.egg-info/SOURCES.txt +39 -0
  7. django_eadmin-0.1.0/django_eadmin.egg-info/dependency_links.txt +1 -0
  8. django_eadmin-0.1.0/django_eadmin.egg-info/requires.txt +1 -0
  9. django_eadmin-0.1.0/django_eadmin.egg-info/top_level.txt +1 -0
  10. django_eadmin-0.1.0/eadmin/__init__.py +6 -0
  11. django_eadmin-0.1.0/eadmin/apps.py +12 -0
  12. django_eadmin-0.1.0/eadmin/context_processors.py +29 -0
  13. django_eadmin-0.1.0/eadmin/forms.py +196 -0
  14. django_eadmin-0.1.0/eadmin/permissions.py +23 -0
  15. django_eadmin-0.1.0/eadmin/py.typed +0 -0
  16. django_eadmin-0.1.0/eadmin/registry.py +157 -0
  17. django_eadmin-0.1.0/eadmin/static/eadmin/eadmin.css +167 -0
  18. django_eadmin-0.1.0/eadmin/static/eadmin/eadmin.js +22 -0
  19. django_eadmin-0.1.0/eadmin/static/eadmin/logo.svg +6 -0
  20. django_eadmin-0.1.0/eadmin/templates/eadmin/base.html +76 -0
  21. django_eadmin-0.1.0/eadmin/templates/eadmin/dashboard.html +3 -0
  22. django_eadmin-0.1.0/eadmin/templates/eadmin/login.html +61 -0
  23. django_eadmin-0.1.0/eadmin/templates/eadmin/model_detail.html +12 -0
  24. django_eadmin-0.1.0/eadmin/templates/eadmin/model_form.html +41 -0
  25. django_eadmin-0.1.0/eadmin/templates/eadmin/model_history.html +6 -0
  26. django_eadmin-0.1.0/eadmin/templates/eadmin/model_list.html +10 -0
  27. django_eadmin-0.1.0/eadmin/templates/eadmin/partials/object_table.html +2 -0
  28. django_eadmin-0.1.0/eadmin/templates/eadmin/password_form.html +6 -0
  29. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/autocomplete.html +11 -0
  30. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/datetime.html +15 -0
  31. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/multiselect.html +16 -0
  32. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/raw_id.html +4 -0
  33. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/select.html +17 -0
  34. django_eadmin-0.1.0/eadmin/templates/eadmin/widgets/transfer_select.html +66 -0
  35. django_eadmin-0.1.0/eadmin/templatetags/__init__.py +1 -0
  36. django_eadmin-0.1.0/eadmin/templatetags/eadmin.py +75 -0
  37. django_eadmin-0.1.0/eadmin/tests/__init__.py +1 -0
  38. django_eadmin-0.1.0/eadmin/urls.py +30 -0
  39. django_eadmin-0.1.0/eadmin/views.py +474 -0
  40. django_eadmin-0.1.0/pyproject.toml +29 -0
  41. django_eadmin-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,4 @@
1
+ recursive-include eadmin/templates *.html
2
+ recursive-include eadmin/static *
3
+ include eadmin/py.typed
4
+ include README-eadmin.md
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-eadmin
3
+ Version: 0.1.0
4
+ Summary: A reusable Tailwind, HTMX, Alpine.js, and DaisyUI Django administration app.
5
+ Author: EAdmin contributors
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Documentation, https://github.com/django-cms/django-cms
8
+ Classifier: Framework :: Django
9
+ Classifier: Framework :: Django :: 5.1
10
+ Classifier: Framework :: Django :: 5.2
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: Django<5.3,>=5.1
16
+
17
+ # django-eadmin
18
+
19
+ `django-eadmin` is a reusable, server-rendered Django administration app built
20
+ with Tailwind CSS, DaisyUI, HTMX, and Alpine.js. It provides a separate
21
+ `/eadmin/` workspace and does not replace Django's built-in `/admin/` site.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ python -m pip install django-eadmin
27
+ ```
28
+
29
+ Put `eadmin` before applications that register models so its templates and
30
+ static assets are discovered first:
31
+
32
+ ```python
33
+ INSTALLED_APPS = [
34
+ "eadmin.apps.EAdminConfig",
35
+ "django.contrib.admin",
36
+ "django.contrib.auth",
37
+ # …remaining Django and project apps
38
+ ]
39
+
40
+ TEMPLATES[0]["OPTIONS"]["context_processors"] += [
41
+ "eadmin.context_processors.navigation",
42
+ ]
43
+ ```
44
+
45
+ Mount its URLs separately from the native admin:
46
+
47
+ ```python
48
+ from django.urls import include, path
49
+
50
+ urlpatterns = [
51
+ path("eadmin/", include("eadmin.urls")),
52
+ path("admin/", admin.site.urls),
53
+ ]
54
+ ```
55
+
56
+ ## Register models
57
+
58
+ Create an `eadmin.py` in any installed Django app:
59
+
60
+ ```python
61
+ from eadmin.registry import ModelAdmin, site
62
+ from .models import Article
63
+
64
+ site.register(Article, ModelAdmin(
65
+ list_display=("title", "state", "updated_at"),
66
+ list_filter=("state",),
67
+ search_fields=("title",),
68
+ fields=("title", "state", "body", "tags"),
69
+ ))
70
+ ```
71
+
72
+ EAdmin discovers these registrations through the installed app configuration.
73
+ It applies Django model permissions to every page and action. By default,
74
+ one-to-one and foreign-key fields use a single select; many-to-many fields use
75
+ a multi-select dropdown. Registrations can opt into autocomplete, raw-ID, or
76
+ transfer controls for exceptional relationships.
77
+
78
+ ## Development install
79
+
80
+ From a checkout containing this package:
81
+
82
+ ```bash
83
+ python -m pip install -e .
84
+ ```
@@ -0,0 +1,68 @@
1
+ # django-eadmin
2
+
3
+ `django-eadmin` is a reusable, server-rendered Django administration app built
4
+ with Tailwind CSS, DaisyUI, HTMX, and Alpine.js. It provides a separate
5
+ `/eadmin/` workspace and does not replace Django's built-in `/admin/` site.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ python -m pip install django-eadmin
11
+ ```
12
+
13
+ Put `eadmin` before applications that register models so its templates and
14
+ static assets are discovered first:
15
+
16
+ ```python
17
+ INSTALLED_APPS = [
18
+ "eadmin.apps.EAdminConfig",
19
+ "django.contrib.admin",
20
+ "django.contrib.auth",
21
+ # …remaining Django and project apps
22
+ ]
23
+
24
+ TEMPLATES[0]["OPTIONS"]["context_processors"] += [
25
+ "eadmin.context_processors.navigation",
26
+ ]
27
+ ```
28
+
29
+ Mount its URLs separately from the native admin:
30
+
31
+ ```python
32
+ from django.urls import include, path
33
+
34
+ urlpatterns = [
35
+ path("eadmin/", include("eadmin.urls")),
36
+ path("admin/", admin.site.urls),
37
+ ]
38
+ ```
39
+
40
+ ## Register models
41
+
42
+ Create an `eadmin.py` in any installed Django app:
43
+
44
+ ```python
45
+ from eadmin.registry import ModelAdmin, site
46
+ from .models import Article
47
+
48
+ site.register(Article, ModelAdmin(
49
+ list_display=("title", "state", "updated_at"),
50
+ list_filter=("state",),
51
+ search_fields=("title",),
52
+ fields=("title", "state", "body", "tags"),
53
+ ))
54
+ ```
55
+
56
+ EAdmin discovers these registrations through the installed app configuration.
57
+ It applies Django model permissions to every page and action. By default,
58
+ one-to-one and foreign-key fields use a single select; many-to-many fields use
59
+ a multi-select dropdown. Registrations can opt into autocomplete, raw-ID, or
60
+ transfer controls for exceptional relationships.
61
+
62
+ ## Development install
63
+
64
+ From a checkout containing this package:
65
+
66
+ ```bash
67
+ python -m pip install -e .
68
+ ```
@@ -0,0 +1,189 @@
1
+ # Django CMS
2
+
3
+ 一个前后端不分离的通用 Django CMS:前台使用 Django Template + HTMX,管理端使用 Tailwind CSS、DaisyUI、HTMX、Alpine.js;缓存及会话使用 Redis。
4
+
5
+ ## 运行环境
6
+
7
+ - Python 3.12+
8
+ - SQLite 3.35+、PostgreSQL 14+ 或 MySQL 8+
9
+ - Redis 6+
10
+
11
+ ## 本地启动
12
+
13
+ ### 1. 准备数据库与 Redis
14
+
15
+ SQLite 不需要单独启动服务;PostgreSQL 或 MySQL 请先创建数据库及账户。Redis 用于缓存与会话。
16
+
17
+ ```sql
18
+ CREATE USER djangocms WITH PASSWORD 'djangocms';
19
+ CREATE DATABASE djangocms OWNER djangocms;
20
+ ```
21
+
22
+ 可选数据库连接:
23
+
24
+ ```text
25
+ SQLite: sqlite:///db.sqlite3
26
+ PostgreSQL: postgresql://djangocms:djangocms@127.0.0.1:5432/djangocms
27
+ MySQL: mysql://djangocms:djangocms@127.0.0.1:3306/djangocms
28
+ Redis: redis://127.0.0.1:6379/1(无密码)
29
+ ```
30
+
31
+ ### 2. 创建 Python 虚拟环境并安装依赖
32
+
33
+ 在项目根目录执行:
34
+
35
+ ```bash
36
+ python -m venv .venv
37
+ source .venv/bin/activate
38
+ python -m pip install --upgrade pip
39
+ python -m pip install -r requirements.txt
40
+ ```
41
+
42
+ Windows PowerShell 请改用:
43
+
44
+ ```powershell
45
+ .venv\Scripts\Activate.ps1
46
+ ```
47
+
48
+ ### 3. 配置环境变量
49
+
50
+ 复制示例配置:
51
+
52
+ ```bash
53
+ cp .env.example .env
54
+ ```
55
+
56
+ 开发环境启动时会自动加载根目录 `.env`。请检查以下配置:
57
+
58
+ ```dotenv
59
+ DJANGO_SECRET_KEY=请替换为本地随机密钥
60
+ DJANGO_DEBUG=true
61
+ DJANGO_VALIDATE_SERVICES_ON_STARTUP=true
62
+ DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1
63
+ # 首选显式驱动:sqlite / postgresql / mysql
64
+ DATABASE_ENGINE=sqlite
65
+ DATABASE_NAME=db.sqlite3
66
+ # PostgreSQL / MySQL 使用以下分项:
67
+ # DATABASE_ENGINE=postgresql
68
+ # DATABASE_NAME=djangocms
69
+ # DATABASE_USER=djangocms
70
+ # DATABASE_PASSWORD=djangocms
71
+ # DATABASE_HOST=127.0.0.1
72
+ # DATABASE_PORT=5432
73
+ # MySQL 可设置 DATABASE_CHARSET=utf8mb4
74
+ # 兼容模式:不设置 DATABASE_ENGINE 时可使用 DATABASE_URL
75
+ # DATABASE_URL=postgresql://djangocms:djangocms@127.0.0.1:5432/djangocms
76
+ # Redis 无密码时:
77
+ REDIS_URL=redis://127.0.0.1:6379/1
78
+ # Redis 有密码时:
79
+ # REDIS_URL=redis://:你的Redis密码@127.0.0.1:6379/1
80
+ CMS_THEME=default
81
+ SITE_NAME=Django CMS
82
+ TIME_ZONE=Asia/Shanghai
83
+ ```
84
+
85
+ `.env` 已被 Git 忽略,不应提交真实密码或生产密钥。生产环境请在部署平台设置同名环境变量。
86
+
87
+ Redis 密码写在 URL 的 `:` 与 `@` 之间;无密码时可使用 `redis://127.0.0.1:6379/1`。如果密码含有 `@`、`:`、`/`、`#`、`?`、`%` 等特殊字符,必须先进行 URL 编码,例如密码 `p@ss:word` 应写成 `p%40ss%3Aword`。
88
+
89
+ 应用启动时会主动验证当前 `DATABASE_ENGINE` / `DATABASE_URL` 指向的数据库连接和 Redis `PING`。任一服务不可达、连接串错误或 Redis 密码不正确时,启动会立即抛出异常,不会提供半可用服务。需要在离线管理命令中临时跳过检查时,可设置 `DJANGO_VALIDATE_SERVICES_ON_STARTUP=false`;正常开发和生产环境应保持为 `true`。
90
+
91
+ 基础依赖使用纯 Python 的 `PyMySQL`,因此不要求本机安装 MySQL 编译工具链。生产环境如需使用 `mysqlclient` 优化,可自行额外安装;项目会优先使用它。更新依赖后执行 `python -m pip install -r requirements.txt`。
92
+
93
+ ### 4. 初始化数据库与管理员
94
+
95
+ 本次核心模型采用新的初始迁移;开发环境请按约定删除旧数据库后再执行迁移,避免将旧的业务表结构与新的 CMS 核心混用。
96
+
97
+ ```bash
98
+ python manage.py migrate
99
+ python manage.py sync_cms_plugins
100
+ python manage.py createsuperuser
101
+ ```
102
+
103
+ ### 5. 启动开发服务器
104
+
105
+ ```bash
106
+ python manage.py runserver
107
+ ```
108
+
109
+ 启动后访问:
110
+
111
+ | 地址 | 用途 |
112
+ | --- | --- |
113
+ | http://127.0.0.1:8000/ | CMS 内容入口 |
114
+ | http://127.0.0.1:8000/eadmin/ | EAdmin:自定义 Tailwind/DaisyUI 管理后台 |
115
+ | http://127.0.0.1:8000/django-admin/ | 保留的 Django 原生管理后台 |
116
+
117
+ `/eadmin/` 与 `/django-admin/` 均需使用上一步创建的管理员账户登录。日常管理请使用 `/eadmin/`;原生后台保留用于兼容与维护。
118
+
119
+ ## 常用命令
120
+
121
+ ```bash
122
+ # 运行测试
123
+ python manage.py test
124
+
125
+ # 检查配置
126
+ python manage.py check
127
+
128
+ # 修改 models.py 后生成迁移
129
+ python manage.py makemigrations
130
+
131
+ # 生产部署时收集静态文件
132
+ python manage.py collectstatic --noinput
133
+ ```
134
+
135
+ ## 主题切换
136
+
137
+ 当前主题由 `CMS_THEME` 环境变量决定,而不是数据库数据。项目内置:
138
+
139
+ ```dotenv
140
+ # 默认简洁主题
141
+ CMS_THEME=default
142
+
143
+ # DaisyUI 复古主题
144
+ CMS_THEME=daisy_retro
145
+ ```
146
+
147
+ 修改 `.env` 后重启 `runserver`。新增主题需放在 `templates/themes/<主题名>/`,并至少提供 `base.html`、`index.html`、`detail.html`。
148
+
149
+ ## 插件
150
+
151
+ 核心采用 django CMS 同类的组合式模型:内容节点拥有命名的 `Placeholder`(占位符),占位符按顺序承载可嵌套的 `PluginInstance`(插件实例)。`PluginType` 只描述由扩展提供的插件类型;具体字段存放在插件实例的结构化数据中。模板使用 `{% load cms_plugins %}` 与 `{% render_placeholder placeholder %}` 渲染插件树。因此富文本、图片、表单、互动或任何领域能力都由独立插件实现,不写入 CMS 核心表。
152
+
153
+ 插件目录为 `plugins/<插件名>/plugin.py`,通过 `register(registry)` 注册。已发现扩展的启用状态与配置保存在 `PluginRecord`。应用可自行注册插件类型、渲染器及数据校验,不需要修改核心模型。
154
+
155
+ 每次新增或更新插件定义后执行 `python manage.py sync_cms_plugins`,将代码中的插件标识、名称和 Schema 同步到后台可管理的 `PluginType`;该命令不会删除已有插件数据。
156
+
157
+ ## EAdmin
158
+
159
+ `eadmin/` 是独立的 Django app,不依赖或覆盖原生 `django.contrib.admin`。它使用自己的注册器、路由和模板,默认地址为 `/eadmin/`。业务模型在各应用的 `eadmin.py` 中注册:
160
+
161
+ ```python
162
+ from eadmin.registry import ModelAdmin, site
163
+ from .models import Content
164
+
165
+ site.register(Content, ModelAdmin(
166
+ list_display=("label", "state", "updated_at"),
167
+ search_fields=("label", "key"),
168
+ fields=("label", "key", "state", "data"),
169
+ ))
170
+ ```
171
+
172
+ 包本身只提供通用注册器、权限、CRUD 视图与 Tailwind CSS、DaisyUI、HTMX、Alpine.js 模板;项目特定模型注册放在应用自己的 `eadmin.py`,因此后续可直接抽离为独立包。
173
+
174
+ 关系字段遵循统一规则:`OneToOneField` 与 `ForeignKey` 使用单选下拉框;`ManyToManyField` 默认使用下拉多选。反向一对多关系使用 EAdmin 的 `InlineModelAdmin` 声明。对于数据量很大或权限分配等特殊场景,注册项可显式改用 `autocomplete_fields`、`raw_id_fields` 或 `filter_horizontal`,不会影响默认通用规则。
175
+
176
+ ### 作为独立包安装
177
+
178
+ EAdmin 已具备 reusable app 的打包配置,发布到 PyPI 后可通过 `python -m pip install django-eadmin` 使用;当前仓库开发时执行 `python -m pip install -e .`。将 `eadmin.apps.EAdminConfig` 放在 `INSTALLED_APPS` 前部,添加 `eadmin.context_processors.navigation`,并通过 `path("eadmin/", include("eadmin.urls"))` 挂载即可。它不会覆盖原生 `/django-admin/`;完整接入示例见 [`README-eadmin.md`](README-eadmin.md)。
179
+
180
+ ## 无 PostgreSQL 时的临时测试
181
+
182
+ 正式开发和生产应使用 PostgreSQL。仅在临时运行测试且本机没有 PostgreSQL 时,可以用 SQLite 覆盖连接:
183
+
184
+ ```bash
185
+ DATABASE_URL=sqlite:///db.sqlite3 python manage.py migrate
186
+ DATABASE_URL=sqlite:///db.sqlite3 python manage.py test
187
+ ```
188
+
189
+ 这只是便捷方案,不应作为生产配置。
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-eadmin
3
+ Version: 0.1.0
4
+ Summary: A reusable Tailwind, HTMX, Alpine.js, and DaisyUI Django administration app.
5
+ Author: EAdmin contributors
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Documentation, https://github.com/django-cms/django-cms
8
+ Classifier: Framework :: Django
9
+ Classifier: Framework :: Django :: 5.1
10
+ Classifier: Framework :: Django :: 5.2
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: Django<5.3,>=5.1
16
+
17
+ # django-eadmin
18
+
19
+ `django-eadmin` is a reusable, server-rendered Django administration app built
20
+ with Tailwind CSS, DaisyUI, HTMX, and Alpine.js. It provides a separate
21
+ `/eadmin/` workspace and does not replace Django's built-in `/admin/` site.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ python -m pip install django-eadmin
27
+ ```
28
+
29
+ Put `eadmin` before applications that register models so its templates and
30
+ static assets are discovered first:
31
+
32
+ ```python
33
+ INSTALLED_APPS = [
34
+ "eadmin.apps.EAdminConfig",
35
+ "django.contrib.admin",
36
+ "django.contrib.auth",
37
+ # …remaining Django and project apps
38
+ ]
39
+
40
+ TEMPLATES[0]["OPTIONS"]["context_processors"] += [
41
+ "eadmin.context_processors.navigation",
42
+ ]
43
+ ```
44
+
45
+ Mount its URLs separately from the native admin:
46
+
47
+ ```python
48
+ from django.urls import include, path
49
+
50
+ urlpatterns = [
51
+ path("eadmin/", include("eadmin.urls")),
52
+ path("admin/", admin.site.urls),
53
+ ]
54
+ ```
55
+
56
+ ## Register models
57
+
58
+ Create an `eadmin.py` in any installed Django app:
59
+
60
+ ```python
61
+ from eadmin.registry import ModelAdmin, site
62
+ from .models import Article
63
+
64
+ site.register(Article, ModelAdmin(
65
+ list_display=("title", "state", "updated_at"),
66
+ list_filter=("state",),
67
+ search_fields=("title",),
68
+ fields=("title", "state", "body", "tags"),
69
+ ))
70
+ ```
71
+
72
+ EAdmin discovers these registrations through the installed app configuration.
73
+ It applies Django model permissions to every page and action. By default,
74
+ one-to-one and foreign-key fields use a single select; many-to-many fields use
75
+ a multi-select dropdown. Registrations can opt into autocomplete, raw-ID, or
76
+ transfer controls for exceptional relationships.
77
+
78
+ ## Development install
79
+
80
+ From a checkout containing this package:
81
+
82
+ ```bash
83
+ python -m pip install -e .
84
+ ```
@@ -0,0 +1,39 @@
1
+ MANIFEST.in
2
+ README-eadmin.md
3
+ README.md
4
+ pyproject.toml
5
+ django_eadmin.egg-info/PKG-INFO
6
+ django_eadmin.egg-info/SOURCES.txt
7
+ django_eadmin.egg-info/dependency_links.txt
8
+ django_eadmin.egg-info/requires.txt
9
+ django_eadmin.egg-info/top_level.txt
10
+ eadmin/__init__.py
11
+ eadmin/apps.py
12
+ eadmin/context_processors.py
13
+ eadmin/forms.py
14
+ eadmin/permissions.py
15
+ eadmin/py.typed
16
+ eadmin/registry.py
17
+ eadmin/urls.py
18
+ eadmin/views.py
19
+ eadmin/static/eadmin/eadmin.css
20
+ eadmin/static/eadmin/eadmin.js
21
+ eadmin/static/eadmin/logo.svg
22
+ eadmin/templates/eadmin/base.html
23
+ eadmin/templates/eadmin/dashboard.html
24
+ eadmin/templates/eadmin/login.html
25
+ eadmin/templates/eadmin/model_detail.html
26
+ eadmin/templates/eadmin/model_form.html
27
+ eadmin/templates/eadmin/model_history.html
28
+ eadmin/templates/eadmin/model_list.html
29
+ eadmin/templates/eadmin/password_form.html
30
+ eadmin/templates/eadmin/partials/object_table.html
31
+ eadmin/templates/eadmin/widgets/autocomplete.html
32
+ eadmin/templates/eadmin/widgets/datetime.html
33
+ eadmin/templates/eadmin/widgets/multiselect.html
34
+ eadmin/templates/eadmin/widgets/raw_id.html
35
+ eadmin/templates/eadmin/widgets/select.html
36
+ eadmin/templates/eadmin/widgets/transfer_select.html
37
+ eadmin/templatetags/__init__.py
38
+ eadmin/templatetags/eadmin.py
39
+ eadmin/tests/__init__.py
@@ -0,0 +1 @@
1
+ Django<5.3,>=5.1
@@ -0,0 +1,6 @@
1
+ """EAdmin: a standalone, HTMX-friendly Django management interface."""
2
+
3
+ default_app_config = "eadmin.apps.EAdminConfig"
4
+ """Reusable Django EAdmin application."""
5
+
6
+ __version__ = "0.1.0"
@@ -0,0 +1,12 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class EAdminConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "eadmin"
7
+ verbose_name = "EAdmin"
8
+
9
+ def ready(self):
10
+ from .registry import site
11
+ site.autodiscover()
12
+
@@ -0,0 +1,29 @@
1
+ from django.apps import apps
2
+ from django.conf import settings
3
+
4
+ from .registry import site
5
+ from .views import admin_verbose_name
6
+
7
+
8
+ def navigation(request):
9
+ current_model_name = getattr(request.resolver_match, "kwargs", {}).get("model_name")
10
+ groups = {}
11
+ entries = []
12
+ for model, config in site.visible_entries(request):
13
+ entry = {"model_name": model._meta.model_name, "verbose_name": admin_verbose_name(model, config), "config": config}
14
+ entries.append(entry)
15
+ key = config.menu_group or model._meta.app_label
16
+ group = groups.setdefault(key, {
17
+ "key": key,
18
+ "label": config.menu_group_label or apps.get_app_config(model._meta.app_label).verbose_name,
19
+ "icon": config.menu_group_icon or config.icon,
20
+ "entries": [],
21
+ "active": False,
22
+ })
23
+ group["entries"].append(entry)
24
+ group["active"] = group["active"] or current_model_name == model._meta.model_name
25
+ return {
26
+ "eadmin_navigation": entries,
27
+ "eadmin_navigation_groups": tuple(groups.values()),
28
+ "eadmin_timezone": settings.TIME_ZONE,
29
+ }