Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Latest commit

 

History

History
74 lines (52 loc) · 3.19 KB

README.rst

File metadata and controls

74 lines (52 loc) · 3.19 KB

Django-Francedata

Provides a database structure, API and import scripts to manage French communes, intercommunalités, départements and régions, with their structure and data from Insee and the DGCL.

This app was created as a part of Open Collectivités.

This repository is now inactive and kept as an archive.

Unaccent extension

If the PostgreSQL user specified in the Django settings is not a superuser, connect to the postgres user and create the Unaccent extension manually:

psql
\c <dbname>
"CREATE EXTENSION  IF NOT EXISTS unaccent;"

Quickstart

  1. Add "francedata" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        "django_json_widget",
        "simple_history",
        "francedata",
    ]
    
  2. Run python manage.py migrate to create the francedata models.

  3. Run the two initialization commands to get the communes, EPCIs, départements and régions structure:

    python manage.py cog_import
    python manage.py banatic_import
    
  4. Visit http://127.0.0.1:8000/admin/ to see the data.

Commands

cog_import:

  • goal: load the following data from the Code officiel géographique (COG): list of regions, departements and communes, with how they are linked and: * insee and siren ids for the regions/departements * insee for the communes
  • parameters: * --level: partial import of only the specified level (the script expects the higher ones to already be installed) Allowed values: regions, departements, communes * --years: import the specified year (min: 2019), by default it imports the latest available one in https://www.data.gouv.fr/fr/datasets/code-officiel-geographique-cog/

banatic_import: