Skip to content

Usage · ⚙️

Run · 🚀

Use codespace, locally, or with Docker.

Start server in codespace and open website in the PORTS tab.

just serve

Start locally with Django at localhost:8000

# ./app
python manage.py runserver

Use with Docker at localhost:8000

docker compose up

Create an admin user (see Django docs) to edit data with

# ./app
python manage.py createsuperuser

See the example of a production deployment in Dockerfile-flyio.

Installation · 🛠️

Run in codespace, install locally, or use Docker (see above).

Codespace is fully configured. Load the data and run a local server with just commands.

# source .venv/bin/activate
just load-data
just serve

Local install and project initialization examples are provided in init-dev-project.sh.

bash ./scripts/init-dev-project.sh
source .venv/bin/activate
cd app
python manage.py runserver

Docker version requires a local database.

docker compose up --build

See the section Data import below or use init the script in a Docker container terminal.

» # /app
» bash ./scripts/init-dev-project.sh

Data import · 🏗️

Import data from ParlGov stable release, create database views, and create an admin user to access the Django admin site for data editing.

# ./app
python manage.py loaddata parlgov-fixture.json
cat apps/views_data/views-data.sql | python manage.py dbshell
python manage.py createsuperuser

Data validation · 🕵🏼‍♀️

All data is validated during the addition to the database with Django. The validate_data command can run these and additional validations (see below).

# ./app
python manage.py validate_data

Additional validations include

  • parties
    • inclusion criteria check — see priority in run_include_checks(party)
  • elections
    • one election result for election
    • seats sum equals seats_total
    • vote share sum in defined interval
    • no seat party (first loser) included
    • max. one party with vote share < 1.0% and 0 seats
  • cabinets
    • PM for one party specified
    • previous election included

Additional scripts data checks

  • cabinet_update_election — check and update election variable in all cabinets
  • election_no_seats_party — show elections with missing coding of first loser (largest party no seats)

Codebook · 📙

All codebook sections are recorded in the database as Markdown entries. They can be edited using the ParlGov website.

A Markdown version of the codebook based on the sections from the database is available on the ParlGov website and can be dumped with a Django management command.

# ./app
python manage.py create_codebook

A shell script creates the codebook, formats the Markdown text file, renders a PDF, and adds the two documents to the documentation.

bash scripts/create-codebook.sh

API · 🔗

The website provides an API with Django REST framework.

It is a read-only API; no login is required.

Documentation with an OpenAPI 3 schema is provided in schema.yaml.


ParlGov Web 2024