Vercel部署django

category
Python
date
Apr 10, 2026
icon
password
slug
vercelDjango
status
Published
summary
使用Vercel部署django
tags
type
Post

一、前期环境配置

1、准备Django项目
(1)创建django项目
(2)创建 requirements.txtpip freeze > requirements.txt (3)创建 runtime.txtecho "python-3.9.6" > runtime.txt (4)创建 vercel.json
(5)修改设置
ALLOWED_HOSTS = ['*']
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
(6)wsgi.py设置
2、设置Vercel
(1)安装Vercel
npm i -g vercel
(2)登录Vercel
vercel login
(3)部署以及后续更新
生产环境运行:vercel --prod
测试环境运行:vercel
开发环境运行:vercel dev

二、遇到的问题

(1)部署时会有选择
notion image
(2)项目结构
my_django_project/ ├── my_app/ │ ├── init.py │ ├── admin.py │ ├── apps.py │ ├── models.py │ ├── tests.py │ ├── views.py │ └── migrations/ ├── my_django_project/ │ ├── init.py │ ├── settings.py │ ├── urls.py │ ├── wsgi.py │ └── asgi.py ├── static/ ├── media/ ├── manage.py ├── requirements.txt ├── runtime.txt └── vercel.json
上一篇
云服务器部署django
下一篇
相关函数
Loading...