Part 7 - Publishing to the internet

 

Pythonanywhere

 

 

Create a pythonanywhere account in www.pythonanywhere.com
Go through the pythonanywhere quick tutorial.




Overview

  • Dashboard - provides you a general view
  • Consoles - allows you to interact with your webserver and project through consoles
  • Files - provides a graphical interface to interact with your files
  • Web - allows you to create a webapp for a Django project
  • Forums - provides you a good support system
  • Account - lets you manage account plans and configurations



Creating a Web app

  1. Go to Web
  2.  + Add a new web app 
  3. Next
  4. Manual configuration (including virtualenvs)
  5. Choose the Python version
  6. Next (wait some seconds)

 

Creating a virtual environment

  1. Go to Consoles
  2. Start a Bash Console
     

    Creating the virtual environment

    mkvirtualenv myfirstenv --python=/usr/bin/python3.10

     

    Activating the virtual environment

    workon myfirstenv



    Installing Django and Pillow

    pip install django
    pip install Pillow

     

  3. Go back to Web and scroll down to: Virtualenv 
    For me having a username jaimedcsilva38130 and a virtual environment myfirstenv the path is:

    /home/jaimedcsilva38130/.virtualenvs/myfirstenv
     

 

Configuring the web server
 

  • Scroll down to Code
  • Sourcecode: /home/jaimedcsilva38130/mysite
  • WSGI configuration file
    import os
    import sys
    
    path = '/home/jaimedcsilva38130/mysite'
    if path not in sys.path:
        sys.path.append(path)
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()
  • Scroll down to Static files and add the following entries for URL and Directory
    Adjust to your username. In my case it's jaimedcsilva38130
     
    URL                       Directory
    /static/                    /home/jaimedcsilva38130/mysite/staticfiles
    /media/                   /home/jaimedcsilva38130/mysite/media

 

Preparing to go to production

Before you finish, set DEBUG to False, whenever you are in production.

DEBUG = False


Add your pythonanywhere domain to ALLOWED_HOSTS 
Add localhost as well for whenever you bring the project back to development.

ALLOWED_HOSTS = ['localhost', 'jaimedcsilva38130.pythonanywhere.com',]

 

Pythonanywhere
 

  • Go to Files and upload your zipped project (maxium size for a single file is ≈ 100MB)


     
  • In Consoles, go to the Bash Console

    Unzip the project
    unzip mysite.zip
    Collect the static files
    python manage.py collectstatic
  • Go to Web 
  • Scroll down to Security and Force HTTPS
  • Reload the web app

Tested with Django 5.2
Pythonanywhere



12 Nov. 2025 | Last Updated: 23 Jan. 2026 | jaimedcsilva

Related
  • Part 1 - Virtual Environment
  • Part 2 - Setting up a Django Project
  • Part 3 - Templates, Views and URLs
  • Part 4 - Static and Media Files
  • Part 5 - Models and Database
  • Part 6 - Connecting everything
  • Part 7 - Publishing to the internet

  • Buy Me a Coffee