Deploying a Django project on PythonAnywhere

1. Git

1-1. Add .gitignore in the base directory

.gitignore

*.pyc
*~
/.vscode
__pycache__
myvenv
db.sqlite3
/static
.DS_Store
*.swp
*.swo

1-2. Push your code to GitHub

$ git add .
$ git commit -m "Initial commit"
$ git push origin master

2. PythonAnywhere

Assuming you already have a PythonAnywhere account

2-1. Start a "Bash" console on PythonAnywhere Dashboard

2-2. Clone your git repo

2-3. Create a virtual environment

2-4. Create a database

2-5. Add a new web app

  1. Hit the logo

  2. Click Web on the menu

  3. Click Add a new web app

  4. Confirm Domain name

    • You have to pay extra money if you want to customize it

  5. Select manual configuration

  6. Select Python 3.6

2-6. Virtualenv configurations

  1. Click Web on the menu

  2. Scroll down

  3. You'll see Enter the path to a virtualenv

  4. Type the following path

2-7. WSGI configuration file

  • Copy & Paste it

  • Change mysite from mysite.settings to the directory name where your settings.py at

  • Save it (I mean, of course)

3. You are now live!

Last updated