目录与 URL 结构
来自陋室
更多操作
Django 项目目录结构
alumni_community/ # 顶层工程目录
├── manage.py # Django 命令入口
├── requirements.txt # 依赖列表
├── README.md # 项目说明文档
├── .gitignore
│
├── alumni_community/ # 主配置目录(project)
│ ├── __init__.py
│ ├── settings.py # 主配置文件
│ ├── urls.py # 全局 URL
│ ├── wsgi.py # WSGI 服务入口
│ ├── asgi.py # ASGI 服务入口
│ └── static/ # 全局静态资源(可选)
│
├── apps/ # 所有独立 app
│ ├── users/ # 用户与权限管理
│ │ ├── migrations/
│ │ ├── templates/users/
│ │ ├── static/users/
│ │ ├── models.py
│ │ ├── views.py
│ │ ├── forms.py
│ │ ├── urls.py
│ │ ├── admin.py
│ │ ├── tests.py
│ │ └── apps.py
│ │
│ ├── posts/ # 帖子 / 评论 / 标签模块
│ │ ├── migrations/
│ │ ├── templates/posts/
│ │ ├── static/posts/
│ │ ├── models.py
│ │ ├── views.py
│ │ ├── forms.py
│ │ ├── urls.py
│ │ ├── admin.py
│ │ ├── tests.py
│ │ └── apps.py
│ │
│ ├── notifications/ # 消息通知中心(回复提醒、系统消息)
│ │ ├── migrations/
│ │ ├── models.py
│ │ ├── views.py
│ │ ├── urls.py
│ │ ├── admin.py
│ │ ├── tests.py
│ │ └── apps.py
│ │
│ ├── dashboard/ # 后台扩展:内容审核、统计
│ │ ├── migrations/
│ │ ├── models.py
│ │ ├── views.py
│ │ ├── urls.py
│ │ ├── templates/dashboard/
│ │ └── admin.py
│ │
│ └── api/ # REST API(可选)
│ ├── serializers.py
│ ├── views.py
│ ├── urls.py
│ └── apps.py
│
├── media/ # 用户上传文件(图片/附件)
│
├── static/ # collectstatic 归档目录(部署时生成)
│
└── scripts/ # 可选,定时任务/工具脚本
├── cron_sync.py
└── init_data.py
项目 URL 结构树
以下为基于多 app 架构的全局 URL 路由结构示意,展示各模块的访问入口与嵌套关系。
alumni_community/urls.py
├── /admin/ -> Django Admin 后台
├── /auth/ -> 用户与权限模块
│ ├── /auth/login/ -> 登录
│ ├── /auth/logout/ -> 登出
│ ├── /auth/register/ -> 注册
│ ├── /auth/password_reset/ -> 找回密码
│ ├── /auth/profile/ -> 用户资料
│ └── /auth/settings/ -> 账号设置
│
├── /u/ -> 用户个人空间(展示层)
│ ├── /u/<uid>/ -> 个人主页
│ ├── /u/<uid>/posts/ -> 用户发帖
│ └── /u/<uid>/comments/ -> 用户评论
│
├── /posts/ -> 帖子与评论模块
│ ├── /posts/ -> 全部帖子列表
│ ├── /posts/<pid>/ -> 帖子详情
│ ├── /posts/create/ -> 发帖
│ ├── /posts/<pid>/edit/ -> 编辑帖子
│ ├── /posts/<pid>/delete/ -> 删除帖子
│ ├── /posts/<pid>/comment/ -> 发表评论
│ └── /tag/<tag>/ -> 标签筛选
│
├── /boards/ -> 板块(学院/主题分区)
│ ├── /boards/ -> 板块首页
│ ├── /boards/<bid>/ -> 某个板块的帖子列表
│ └── /boards/<bid>/create/ -> 在板块发帖
│
├── /notifications/ -> 消息通知中心
│ ├── /notifications/ -> 通知列表
│ ├── /notifications/read/<nid>/ -> 标记已读
│ └── /messages/ -> 私信模块(可选)
│ ├── /messages/ -> 私信首页
│ ├── /messages/<uid>/ -> 与某用户的对话
│ └── /messages/send/ -> 发送私信
│
├── /dashboard/ -> 扩展后台(社区版)
│ ├── /dashboard/ -> 后台主界面
│ ├── /dashboard/users/ -> 用户管理
│ ├── /dashboard/posts/ -> 帖子审核
│ ├── /dashboard/reports/ -> 举报处理
│ ├── /dashboard/statistics/ -> 数据统计(PV/UV/发帖量)
│ └── /dashboard/settings/ -> 系统配置
│
├── /api/ -> REST API(可选)
│ ├── /api/auth/ -> 用户鉴权 API
│ ├── /api/posts/ -> 帖子 API
│ ├── /api/boards/ -> 板块 API
│ └── /api/notifications/ -> 通知 API
│
├── /search/ -> 全局搜索
│ ├── /search/?q= -> 内容检索
│ └── /search/advanced/ -> 高级搜索
│
└── /media/ -> 用户上传文件访问路径(需配置)