0% found this document useful (0 votes)
6 views6 pages

Host Django Project on PythonAnywhere Guide

This document provides a step-by-step tutorial for hosting a Django project on PythonAnywhere, starting from local project preparation to making the project live. Key steps include creating a ZIP file of the project, uploading it to PythonAnywhere, configuring the WSGI file, and updating allowed hosts for security. Optional best practices such as creating a virtual environment and using MySQL are also suggested.

Uploaded by

hago sohani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Host Django Project on PythonAnywhere Guide

This document provides a step-by-step tutorial for hosting a Django project on PythonAnywhere, starting from local project preparation to making the project live. Key steps include creating a ZIP file of the project, uploading it to PythonAnywhere, configuring the WSGI file, and updating allowed hosts for security. Optional best practices such as creating a virtual environment and using MySQL are also suggested.

Uploaded by

hago sohani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python developer interview tips

Absolutely! Here is the complete, clean, step-by-step tutorial for hosting ANY
Django project on PythonAnywhere — exactly what we did, but now organized
properly and beginner-friendly.

🚀 Full Tutorial: How to Host a Django Project on


PythonAnywhere (Free)
This guide works for ANY Django project, including yours.

⭐ STEP 1 — Prepare Your Project Locally


Before uploading, make sure:

✔ Your Django project structure is like:


cpp

project_root/
│ [Link]
│ db.sqlite3
│ [Link] (optional but recommended)

├── your_project/ ← [Link], [Link], [Link]
└── your_app/ ← models, views, templates

✔ Collect static files (optional)


In VS Code or terminal:

nginx

python [Link] collectstatic

⭐ STEP 2 — Create a ZIP File


Zip the entire project folder, for example:

1/6
css

StudentManagementSystem_CURD-[Link]

Make sure the ZIP contains:

python-repl

[Link]
db.sqlite3
student_mgmt/
students/
...

⭐ STEP 3 — Upload to PythonAnywhere


1. Go to: [Link]
2. Create FREE account
3. Click Files tab
4. Upload your ZIP file
5. After upload, open Bash Console

⭐ STEP 4 — Unzip the Project


In Bash:

css

unzip StudentManagementSystem_CURD-[Link]

This will create a folder:

css

StudentManagementSystem_CURD-DjangoApplication-main/

⭐ STEP 5 — Move the project to HOME directory


2/6
Go inside:

bash

cd StudentManagementSystem_CURD-DjangoApplication-main

Move the main project folder:

bash

mv student_mgmt ~/student_mgmt

Check:

bash

ls ~/student_mgmt

You must see:

[Link]
db.sqlite3
student_mgmt/
students/

⭐ STEP 6 — Create a PythonAnywhere Web App


1. Go to Web tab
2. Click Add New Web App
3. Choose:
Manual Configuration
Python version → 3.10

PythonAnywhere creates:

bash

/var/www/yourusername_pythonanywhere_com_wsgi.py

3/6
⭐ STEP 7 — Install Django in PythonAnywhere
In Bash:

nginx

pip install django

⭐ STEP 8 — Configure WSGI File


Go to Web → WSGI configuration file

Replace everything with:

python

import sys
import os

# Add your project path


path = '/home/RajeshSohani/student_mgmt'
if path not in [Link]:
[Link](path)

[Link]('DJANGO_SETTINGS_MODULE', 'student_mgmt.settings')

from [Link] import get_wsgi_application


application = get_wsgi_application()

Save it.

⭐ STEP 9 — Update ALLOWED_HOSTS


Open your settings file:

bash

~/student_mgmt/student_mgmt/[Link]

Find:

4/6
python

ALLOWED_HOSTS = []

Replace with:

python

ALLOWED_HOSTS = ['[Link]']

Save.

⭐ STEP 10 — Reload Website


Go to Web → Reload
Then visit your site:

🔗 [Link]
Your Django project is live! 🎉

⭐ Optional (But Good Practices)


✔ Create virtual environment
✔ Install requirements file
✔ Setup static files
✔ Switch to MySQL instead of SQLite
If you want these, I can guide you step-by-step.

🎉 Final Result
You now know the complete professional process:

Step Task Purpose

1 prepare project ensure Django runs

5/6
Step Task Purpose

2 zip project upload easily

3 upload ZIP move project online

4 unzip extract code

5 move folders correct project path

6 create web app host website

7 install Django make


PythonAnywhere run it

8 configure WSGI connect Django to


server

9 allowed hosts security

10 reload final live website

If you want, I can generate


✅ video-style step-by-step tutorial
or
✅ a PDF guide
or
✅ a GitHub README template for hosting
Just tell me!

6/6

You might also like