Jul 1, 2015

how I deployed my website on pythonanywhere.com


  • manually create web app
  • choose python 2.7
  • create virtual environment with django 1.8 (generally follow the "djangobook" online) but without the whitenoise package.
    mkvirtualenv django18 workon django18 pip install django django-admin.py --version
  • replace the wsgi file with the following
# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:
import os
import sys
# assuming your django settings file is at '/home/myusername/mysite/mysite/settings.py'
path = '/home/whymrandersonwhy/my-first-blog'
if path not in sys.path:
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
## Uncomment the lines below depending on your Django version
###### 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()

to restore app after deletion

create app
select manual install
paste above wsgi
enter django18 in virtualenv section


  •  push website to github and tell pythonanywere to grab it by running its command bash
    • this step has a lot of checking needs to be done on names, directory's names, etc.. see djangobook (the mysite/mysite thing is really confusing...)
    • first create my-first-blog/ folder under root 
    • run git pull from github

to sync your local website on your computer to the website on pyanywhere
  1. first push local changes to github
  2. on pythonanywhere open a bash console and go to your git repository (in my case "cd my-first-blog")
  3. then then pull the changes from github by running
    git pull https://github.com/whymranderson/my-first-blog.git

mkvirtualenv django18
workon django18
pip install django
django-admin.py --version
git clone https://github.com/whymranderson/my-first-blog.git

copy blogger的文章html code
用notepad去replace doni內的teachnote.html
push to github

my database entity-relation model

No comments: