在Pythonanywhere上部署Django
1 在github上创建一个仓库blog
2 克隆到本地,添加Django项目,再推送到github
3 克隆到pythonanywhere,以后每次更新用git pull即可
4 在pythonanywhere上创建venv
virtualenv venv source venv/bin/activate pip install -r requirements.txt 安装应用所需的包
5 配置web选项:
virtualenv /path/to/your/venv/ eg. /home/suqingdong/web/mysite
配置/var/www/.....wsgi.py文件
import os import sys path = '/home/suqingdong/web/mysite' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' from django.core.wsgi import get_wsgi_application from django.contrib.staticfiles.handlers import StaticFilesHandler application = StaticFilesHandler(get_wsgi_application())
6 迁移数据库,创建超级用户,收集静态文件等
KEEP LEARNING!