Skip to content

Development · 💻

See Python development dependencies in requirements-dev.txt and a documentation of environment variables in .env.example. uv is used as a venv/pip replacement for some development tasks.

Commands · 🏃🏼

Use just command runner for local development and in codespace.

List commands with

just

Testing · 🧪

Run tests and check test coverage with

# (.venv) ./app
pytest --cov

Tests are run randomly with pytest-randomly. This can be disabled with

# (.venv) ./app
pytest --cov --randomly-dont-reorganize

Database · 🫙

Tables · 📂

Database tables use prefixes.

  • data — data tables (e.g., parties, elections, cabinets)
  • docs — documentation tables (e.g., codebook, news)
  • view – main data tables (database views, see below)

Additional tables are included by Django in the app database (parlgov.sqlite).

A visualization of the data tables is provided in graph-models_data.png (see below).

Normalization · ✔️

The database created with the Django models is normalized except for the election attribute of the Cabinet model. An election is added or updated to a cabinet on save. A later change to the election that changes the previous election for the cabinet is not updated for the cabinet automatically.

All cabinets' elections can be checked and updated with

# (.venv) ./app
python manage.py update_cabinet_election

Views · 🔬

There are three main tables (parties, elections, cabinets) provided as database views. They include the most frequently used information from the primary database tables.

These views are created during the initialization of the project (see Data import).

The three main views are not included as Django models in the project.

Miscellaneous · 🗂️

Documentation · 📚

Start documentation at localhost:80

# (.venv) ./
mkdocs serve --dev-addr localhost:8888

Build static site documentation

# (.venv) ./
mkdocs build --clean --strict

Graph models · 📐

Create or update graph models — locally only

# (.venv) ./
./scripts/graph-data-models.sh

The script needs graphviz installed and is included only locally to keep testing, Docker, and codespace configuration lean.

Install on macOS with homebrew

brew install graphviz

Install on Ubuntu and Debian (e.g., codespace) with

sudo apt-get install graphviz graphviz-dev

graph-models