Contributing

See also

Django in the Software Development Handbook

Setup

  1. Install PostgreSQL and RabbitMQ

  2. Create a Python 3.11 virtual environment

  3. Install development dependencies:

    pip install pip-tools
    pip-sync requirements_dev.txt
    
  4. Set up the git pre-commit hook:

    pre-commit install
    
  5. Create the database:

    createdb data_registry
    
  6. Run database migrations and create a superuser:

    ./manage.py migrate
    ./manage.py createsuperuser
    

Development

The default values in the settings.py file should be appropriate as-is. You can override them by setting Environment variables.

Backend

  • Run the server, replacing USERNAME and PASSWORD:

    env SCRAPYD_URL=https://USERNAME:PASSWORD@collect.kingfisher.open-contracting.org ./manage.py runserver
    

    Note

    To test integration with the production version of Spoonbill, you also need to set the SPOONBILL_API_USERNAME and SPOONBILL_API_PASSWORD environment variables.

  • Open a Django shell:

    ./manage.py shell
    

    When using Docker:

    docker compose run -e LOG_LEVEL=DEBUG --rm web python manage.py shell
    
  • Run tests:

    ./manage.py test
    

Implementation notes

  • As much as possible, use a single entrypoint (API) to other applications to limit coupling.

  • This project uses Django signals (reference), which makes the code harder to understand, but guarantees that our desired actions are performed, regardless of how the related operation was called (for example, whether from a model, queryset or cascade).

  • The update_fields argument must include any auto_now fields.

Frontend

Autobuild the stylesheets

npx webpack --watch

Update the flags

Hampus Joakim Borgos maintains more accurate flags than Lipis.

curl -LO https://github.com/hampusborgos/country-flags/archive/refs/heads/main.zip
unzip main.zip
rm -rf data_registry/static/img/flags/
mv country-flags-main/ data_registry/static/img/flags
rm -rf country-flags-main/ main.zip

Translate with Transifex

See how to update Django translations and use Transifex.