一步不丢,复制粘贴即可,下次直接照着跑
一、前置准备(仅第一次需要)
- 安装 Git:https://git-scm.com/download/win
- 安装完 必须重启 PowerShell
二、完整一键流程(永久通用)
打开 PowerShell,依次复制运行:
1. 克隆项目
powershell
git clone --depth 1 https://github.com/Lawyer-ray/FachuanHybridSystem.git
cd FachuanHybridSystem\backend
2. 安装 uv(Python 环境管理器)
powershell
irm https://astral.sh/uv/install.ps1 | iex
✅ 安装完 关闭 PowerShell 重新打开,再进入目录:
powershell
cd C:\Users\29650\FachuanHybridSystem\backend
3. 创建虚拟环境
powershell
uv venv --python 3.12
4. 激活虚拟环境
powershell
.venv\Scripts\activate
5. 安装全部依赖
powershell
uv sync
6. 复制环境变量配置
powershell
copy .env.example .env
7. 进入真正的项目目录(关键!)
powershell
cd apiSystem
8. 数据库迁移
powershell
python manage.py migrate
9. 收集静态文件
powershell
python manage.py collectstatic --noinput
10. 启动项目 🎉
powershell
python manage.py runserver
三、启动成功
停止服务:Ctrl + C
四、下次快速进入(最简版)
每次打开电脑,只需运行这 5 行:
powershell
cd C:\Users\29650\FachuanHybridSystem\backend
.venv\Scripts\activate
cd apiSystem
python manage.py migrate
python manage.py runserver
五、常见问题
git不是命令 → 装 Gituv不是命令 → 重启 PowerShell- 找不到 manage.py → 必须
cd apiSystem - 依赖报错 → 重新运行
uv sync