🐍 Pyversity Beginner Tutorial

Deploy Django on
PythonAnywhere

From zero to live website — entirely in your browser, completely free. No server knowledge needed!

7 Steps
~30 Minutes
FREE Forever
🐍
Your Progress
💡
What is PythonAnywhere? PythonAnywhere is a cloud platform made for Python developers. It gives you a free hosting account, a Bash terminal in your browser, and a live URL — no credit card needed. Perfect for student projects!
1
Step 1
Create a Free Account
🎉
First things first — let's get you a free PythonAnywhere account. It takes about 2 minutes!
  • Go to pythonanywhere.com and click "Start running Python online"
  • Click "Create a Beginner account" — it's completely free!
  • Fill in your username, email, and password. Your website will live at yourusername.pythonanywhere.com
  • Confirm your email address, then log in to the dashboard
Choose your username wisely! Your live website URL will be yourusername.pythonanywhere.com — so pick something you're proud to share!
2
Step 2
Push Your Django Project to GitHub
🐙
PythonAnywhere will download your project from GitHub. This is the cleanest and most professional way to get your code online.

Run these commands in your local terminal (where your Django project folder is):

bash — your local machine
# 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
⚠️
Don't have Git set up? Visit github.com, create a free account, create a new repository, and follow their "push an existing repository" instructions.
📄
What is requirements.txt? It's a file that tells PythonAnywhere exactly which Python packages to install — like Django, Pillow, etc. Without it, your project won't run!
3
Step 3
Open a Bash Console & Clone Your Project
🖥️
PythonAnywhere gives you a terminal right in your browser — no software to install!
  • From your PythonAnywhere dashboard, click the "Consoles" tab at the top
  • Click "Bash" to open a new terminal
  • Type the command below to download your project from GitHub
bash — PythonAnywhere console
git clone https://github.com/YOUR_USERNAME/your-project.git
🔁 Replace: YOUR_USERNAME with your GitHub username, and your-project with your repository name.

After cloning, check the folder is there:

bash
ls

You should see your project folder listed! 🎉

4
Step 4
Create a Virtual Environment & Install Packages
📦
A virtual environment is like a private room for your project's packages — it keeps everything tidy and separate.
bash — PythonAnywhere console
# 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
🔁 Replace: myproject-venv with a name you like (e.g. mysite-venv), and your-project-folder with the name of the folder that was cloned.
💡
What does mkvirtualenv do? It's a handy PythonAnywhere tool that creates an isolated Python environment. Think of it like a fresh, clean Python installation just for your project!

To check what's installed, run: pip list — you should see Django in the list!

5
Step 5
Create the Web App & Configure WSGI
⚙️
This is the most important step! We tell PythonAnywhere how to run your Django project through the Web tab.

Part A — Create the Web App:

  • Go to the Web tab in your PythonAnywhere dashboard
  • Click "Add a new web app" → click Next
  • Choose "Manual configuration" (NOT "Django" — that's only for new projects)
  • Select Python 3.10 and click Next
⚠️
Important: Choose "Manual Configuration"! If you choose the "Django" option, it creates a brand new project. You want "Manual Configuration" to connect your existing project.

Part B — Set the Virtualenv path:

On your web app page, find the Virtualenv section and type:

virtualenv path
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:

python — WSGI file
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()
🔁 Replace:
yourusername → your PythonAnywhere username
your-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).

6
Step 6
Update settings.py & Run Migrations
🔧
We need to tell Django that it's now running on PythonAnywhere's servers, and set up our database.

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:

python — settings.py
# Find ALLOWED_HOSTS and update it:
ALLOWED_HOSTS = ['yourusername.pythonanywhere.com']

# Find DEBUG and set it to False for production:
DEBUG = False
🔁 Replace: yourusername with your actual PythonAnywhere username.
🔒
Why DEBUG = False? In development you want detailed error messages. But on a live website, showing error details to visitors is a security risk — so we turn it off!

Part B — Run database migrations:

Go back to your Bash console (activate your venv first if needed) and run:

bash — PythonAnywhere console
# 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
🗄️
What is migrate? It creates all the database tables your Django app needs. Always run this when deploying for the first time, or when you add new models!
7
Step 7
Reload & Visit Your Live Website! 🚀
🌐
The final moment — time to go live!
  • Go back to the Web tab in PythonAnywhere
  • Click the big green "Reload" button at the top
  • Wait a few seconds, then click your website link: yourusername.pythonanywhere.com
  • 🎉 Your Django website is now LIVE on the internet!
🐛
Seeing an error? Don't panic! Go to the Web tab → scroll down to find Error log and click it. The error message will tell you exactly what went wrong. Common fixes:

ModuleNotFoundError → check your WSGI file paths
DisallowedHost → update ALLOWED_HOSTS in settings.py
Import Error → make sure your virtualenv is set correctly
🔄
Updating your site later? Push changes to GitHub → open Bash console → run git pull → go to Web tab → click Reload. That's it!
PythonAnywhere Free Tier LimitsAmount
Web apps1
Storage512 MB
CPU time100 sec/day
MySQL databases1
ExpiryNever (renew every 3 months)
🎊

You Did It, Developer! 🐍

Your Django website is now live on the internet at yourusername.pythonanywhere.com

Share it with your friends, put it on your CV, and keep building amazing things! You're a real web developer now.