Laws.Africa Developer Guide
  • Laws.Africa Developer Guide
  • Get Started
    • Introduction
    • Quick start
    • Works and expressions
    • Webhooks
    • Changelog
  • Tutorial
    • About the tutorial
    • Module 1: Build a legislation reader
      • Introductory concepts
      • Create a basic Django app
      • Create database models
      • Fetching the data
      • Work listing page
      • Expression detail page
      • Styling with Law Widgets
      • Adding interactivity
      • Staying up to date
    • Module 2: Enrichments and interactivity
      • Basic enrichments
      • Advanced enrichments
      • Advanced interactivity
    • Module 3: Text extraction for search and analysis
      • Why extracting text is important
      • Basics of text extraction
      • Advanced text extraction
      • Extracting text for analysis and machine learning
  • Content API Reference
    • About the Content API
    • Authentication
    • Pagination
    • Places
    • All work expressions
    • Single work expression
      • Commencements
      • Embedded images
      • Publication document
      • Table of Contents
      • Timeline
    • Taxonomy topics
    • Enrichment datasets
  • AI API Reference
    • About the AI API
    • Authentication
    • Knowledge Bases
  • How-to Guides
    • How to use the Table of Contents API
    • How to download images
Powered by GitBook
On this page
  • In this section
  • Create a basic Django app
  1. Tutorial
  2. Module 1: Build a legislation reader

Create a basic Django app

PreviousIntroductory conceptsNextCreate database models

Last updated 1 year ago

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 , 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 , we'll ingest some live data from the publicly available Indigo API in Fetching the data.

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

Django tutorial
Django tutorial
Django Admin