From zero to live website — entirely in your browser, completely free. No server knowledge needed!
yourusername.pythonanywhere.com
yourusername.pythonanywhere.com — so pick something you're proud to share!
Run these commands in your local terminal (where your Django project folder is):
# Navigate to your project folder (the one with manage.py) cd your-project-folder # Create requirements.txt — this lists all your packages pip freeze > requirements.txt # Set up Git if you haven't already git init git add . git commit -m "Ready to deploy" # Push to GitHub (create a repo on github.com first) git remote add origin https://github.com/YOUR_USERNAME/your-project.git git push -u origin main
git clone https://github.com/YOUR_USERNAME/your-project.git
YOUR_USERNAME with your GitHub username, and your-project with your repository name.
After cloning, check the folder is there:
ls
You should see your project folder listed! 🎉
# Create a virtual environment (name it after your project) mkvirtualenv --python=/usr/bin/python3.10 myproject-venv # You'll see (myproject-venv) appear at the start — that means it's active! # Navigate into your project folder cd your-project-folder # Install all your packages pip install -r requirements.txt
myproject-venv with a name you like (e.g. mysite-venv), and your-project-folder with the name of the folder that was cloned.
To check what's installed, run: pip list — you should see Django in the list!
Part A — Create the Web App:
Part B — Set the Virtualenv path:
On your web app page, find the Virtualenv section and type:
myproject-venv
PythonAnywhere will auto-complete it to the full path. Click OK ✓
Part C — Edit the WSGI file:
In the Code section of the Web tab, click on the WSGI configuration file link. It will open a file editor. Delete everything and paste this instead:
import os import sys # Replace 'yourusername' and 'your-project-folder' below path = '/home/yourusername/your-project-folder' if path not in sys.path: sys.path.insert(0, path) # Replace 'yourprojectname' with the folder containing settings.py os.environ['DJANGO_SETTINGS_MODULE'] = 'yourprojectname.settings' from django.core.wsgi import get_wsgi_application application = get_wsgi_application()
yourusername → your PythonAnywhere usernameyour-project-folder → the folder name (with manage.py in it)yourprojectname → the folder name that contains settings.py
Click the green Save button (top right of the file editor).
Part A — Update settings.py:
Open your project's settings.py file (using the Files tab in PythonAnywhere or your editor) and update these two lines:
# Find ALLOWED_HOSTS and update it: ALLOWED_HOSTS = ['yourusername.pythonanywhere.com'] # Find DEBUG and set it to False for production: DEBUG = False
yourusername with your actual PythonAnywhere username.
Part B — Run database migrations:
Go back to your Bash console (activate your venv first if needed) and run:
# Make sure you're in the project folder and venv is active workon myproject-venv cd your-project-folder # Run migrations to set up your database python manage.py migrate # Collect static files (CSS, images, JS) python manage.py collectstatic
yourusername.pythonanywhere.com
ModuleNotFoundError → check your WSGI file pathsDisallowedHost → update ALLOWED_HOSTS in settings.pyImport Error → make sure your virtualenv is set correctly
git pull → go to Web tab → click Reload. That's it!
| PythonAnywhere Free Tier Limits | Amount |
|---|---|
| Web apps | 1 |
| Storage | 512 MB |
| CPU time | 100 sec/day |
| MySQL databases | 1 |
| Expiry | Never (renew every 3 months) |