Django Deployment
Option 1: Deploy to www.pythonanywhere.com
Collect the requirement of you development environment
In development environment1
2➜ git:(master) ✗ source activate dj
(dj) ➜ git:(master) ✗ pip freeze > requirement.txtUpload code to Github
Register an account on https://www.pythonanywhere.com
Create a Web App
Create Virtual Env:
Open a Console1
mkvirtualenv --python=python3.6 dj
Download code and install required packages
1
2
3
4git clone https://github.com/chunkai-meng/QualityHats-Django.git
cd QualityHats-Django
pip install -r requirements.txt
python manage.py migrateCreate a supper user
1
2# if havn't created super user
python manage.py createsuperuser <username>Back to Deshboard Page - Web - Add a new web app
- Go to “web app setup” Page, input the following setting (change to your own)
- Virtualenv: /home/hustmck/.virtualenvs/myproj
- Source code: /home/hustmck/QualityHats-Django
- Edit WSGI configuration file:/var/www/hustmck_pythonanywhere_com_wsgi.py
- delete the Hello World code
- Edit the Django code block as below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:
import os
import sys
#
## assuming your django settings file is at '/home/hustmck/mysite/mysite/settings.py'
## and your manage.py is is at '/home/hustmck/mysite/manage.py'
path = '/home/hustmck/QualityHats-Django'
if path not in sys.path:
sys.path.append(path)
os.chdir(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE","qualityhats.settings")
import django
django.setup()
#os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
#
## then, for django >=1.5:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
## or, for older django <=1.4
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()
- Go to “web app setup” Page, input the following setting (change to your own)
Reload your app
Open your URL (Open Dashboard - Web tab - the link is on the top)
Deploy to AWS
coming soon