Skip to content
Django
Deploy Options
Pythonanywhere

Python AnyWhere Deployment

Method 1: By Creating & Uploading a Django Project

  1. Create your account on Python Anywhere (opens in a new tab).
  2. Make sure you have a Django project on GitHub.
⚠️

Note: You can deploy only one web app on the free plan.

Create a new web app

  1. Go to the dashboard and click on the Web tab.
  2. Click on the Add a new web app button.
  3. Select the Manual configuration option.
  4. Choose the Python option.
  5. Set the Python version to the version you are using.
  6. Set the Web app name to the name of your project.
  7. Click on the Next button.

Your web app will be created.

Enable HTTPS

  1. Enable the Force HTTPS option.
  2. You can view you web app at https://yourusername.pythonanywhere.com.

Uploading your project

  1. Go to the Files tab and click on the Upload a file button.
  2. Make sure your project is in a zip file.
  3. Upload the zip file.

Unzipping your project

  1. Go to the Consoles tab and open a new console.
  2. Run the following command to unzip your project:
Terminal
# List the files in the current directory
ls -l
 
# Unzip the project
unzip your_project.zip

Setting up the web app

  1. Go to the Web tab and click on the Reload button.
  2. Set the Source code to the path of your project.
  3. Set the static files to the path of your project's static folder.
  4. Set the media files to the path of your project's media folder.
  5. Set the WSGI configuration file to the path of your project's wsgi.py file. Open in new tab.
wsgi.py
 
import os
import sys
 
# add your project directory to the sys.path
project_home = '/home/mohdirfan/your_project'
if project_home not in sys.path:
    sys.path.insert(0, project_home)
 
# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = 'your_project.settings'
 
 
# serve django via WSGI
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
  1. Save the changes and reload the web app.
  2. Go to Files tab and update the settings.py file.
  3. Change ALLOWED_HOSTS in settings.py to ['yourusername.pythonanywhere.com'] or ['*'].

Now you can view your web app at https://yourusername.pythonanywhere.com.

Method 2: Using Github

3. Set up the web app

  1. Set the Web app configuration to the path of your project.
  2. Set the WSGI configuration file to the path of your project's wsgi.py file.

3. Install requirements

  1. Go to the Consoles tab and open a new console.
  2. Run the following command to install the requirements:
Terminal
pip install -r requirements.txt