DIY: Hello World

At this point in the course we are going to start over and build a series of applications in a Django project. To review terminology, in the work that you have done so far:

We first need to make a new project within our django_projects folder. It is time to finish and then stop working on the locallibrary project. Just keep it working so you can refer back to it as you build new applications.

Making a New Project and Application

Start a shell with virtual environment (if needed) and go into your django_projects folder and start a new project and an application:

workon django3                  # as needed
cd ~/django_projects
django-admin startproject dj4e

cd ~/django_projects/dj4e
python3 startapp home

Starting Django in the new project (local computer)

Only use this if yu are running on your local compuer. Skip to the next set of instructions if you are on PythonAnywhere.

cd ~/django_projects/dj4e
python3 runserver

In general as you make changes to the files below, runserver will monitor for file changes and restart itself although sometimes you do want to abort runserver and restart it manually to make sure it sees every new change.

Switching to the new project (on PythonAnywhere)

Under your Web tab, Set the following:

Source Code:   /home/drchuck/django_projects/dj4e
Working Directory:   /home/drchuck/django_projects/dj4e

The virtual environment should be pointing to your django3 virtual environment:


Replace drchuck above with your PythonAnywhere account name.

Your WGSI Configuration file under the Web tab on PythonAnywhere should be replaced with this text:

import os
import sys

path = os.path.expanduser('~/django_projects/dj4e')
if path not in sys.path:
    sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'dj4e.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

Of course once you make these changes and other chenges below, you need to Reload your application.

Files to Edit/Create

These are the steps to build your "Hello World" application.