Create a basic Django app

In this section

  • Setup a Python environment

  • Create a basic Django app

Create a basic Django app

We will build our example application using Django. There is nothing special about using Django, you can easily build an equivalent application using another language and framework.

Follow the first steps for setting up a Django app using the Django tutorial, using legislation and reader for your project and app, respectively.

Ignore the instruction to create a urls.py file in your reader app; we'll cover these in Expression detail page.

Here is a summary of the commands to run:

python3 -m venv .venv
source .venv/bin/activate
pip install django==3.2
pip install requests
django-admin startproject legislation
cd legislation

python manage.py startapp reader
# see Create database models
python manage.py makemigrations reader
python manage.py migrate

# see Fetching the data
python manage.py ingest_capetown_bylaws <YOUR_AUTH_TOKEN>
python manage.py runserver

We'll use the default settings, adding legislation and reader to the the list of installed apps:

settings.py
INSTALLED_APPS = [
    'legislation',
    'reader',
    'django.contrib.admin',
    ...
]

Instead of creating objects manually to play with, as they do in the Django tutorial, we'll ingest some live data from the publicly available Indigo API in Fetching the data.

We won't cover the Django Admin in this tutorial, but you might find it useful.

Last updated