Add page-tree decision and Wagtail M2M implementation note
- 04-architecture 3.1: add ProjectIndexPage; authoritative page tree (project pages live under /projects/, never under scenario pages); ScenarioPage renders projects via query; filtering lives in ProjectIndexPage.get_context(), no separate Django view; Page M2M fields must use modelcluster ParentalManyToManyField - 06-tasks: sync T-102 row/detail and T-204 quick-table accordingly - routes: point project list page back to the 3.1 tree - progress.md: append maintenance record Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,12 +61,32 @@ SQLite db.sqlite3
|
||||
| `HomePage` | Page | 首页,展示场景入口、推荐骨架、最新文章。 |
|
||||
| `ScenarioIndexPage` | Page | 场景总览页。 |
|
||||
| `ScenarioPage` | Page | 单个场景页,如 SaaS、管理后台、API 服务。 |
|
||||
| `ProjectIndexPage` | Page | 项目列表页(`/projects/`),承载筛选与分页。 |
|
||||
| `SkeletonProjectPage` | Page | 骨架项目详情页。 |
|
||||
| `ArticleIndexPage` | Page | 文章列表。 |
|
||||
| `ArticlePage` | Page | 评测、对比、避坑指南等内容文章。 |
|
||||
|
||||
模型归属:`HomePage` 在 `home` app(`wagtail start` 生成,沿用不改名);其余 Page、Snippet 和文章模型集中在 `core` app(见本文第六节)。
|
||||
|
||||
**页面树结构(唯一权威)**:
|
||||
|
||||
```text
|
||||
HomePage (/)
|
||||
├── ScenarioIndexPage (/scenarios/)
|
||||
│ └── ScenarioPage (/scenarios/{slug}/)
|
||||
├── ProjectIndexPage (/projects/)
|
||||
│ └── SkeletonProjectPage (/projects/{slug}/)
|
||||
└── ArticleIndexPage (/articles/)
|
||||
└── ArticlePage (/articles/{slug}/)
|
||||
```
|
||||
|
||||
- 项目详情页统一挂在 `ProjectIndexPage` 下,**不挂在场景页下**:一个项目属于多个场景(多对多),而页面树上只能有一个父节点。
|
||||
- `ScenarioPage` 没有子项目页;它通过查询 `SkeletonProjectPage.objects.live().filter(scenarios=...)` 渲染本场景的项目列表。
|
||||
- 列表筛选与分页在 `ProjectIndexPage.get_context()` 中做服务端查询实现(参数契约见 3.4),**不另建独立 Django view**。
|
||||
- `/languages/{slug}/`、`/frameworks/{slug}/` MVP 由筛选参数替代,不建 Page(见 `routes.md`)。
|
||||
|
||||
**Wagtail 实现注意**:Page 模型上的多对多字段(`scenarios`、`languages`、`frameworks`、`databases`、`features`)必须用 modelcluster 的 `ParentalManyToManyField`,不能用 Django 普通 `ManyToManyField`,否则后台编辑、草稿和预览会出错。
|
||||
|
||||
### 3.2 Snippet / 辅助模型
|
||||
|
||||
| 模型 | 说明 |
|
||||
|
||||
Reference in New Issue
Block a user