A Django app to provide 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.
Project description
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.
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
Add “francedata” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... "django_json_widget", "simple_history", "francedata", ]
Run python manage.py migrate to create the francedata models.
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
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:
goal: load the following data from the Banatic: * siren ids and population data for the communes * insee for the communes
The script expects that cog_import was already run and that the communes level is passed before the epci level.
parameters: * –level: partial import of only the specified level. Allowed values: communes, epci * –years: import the specified year (min: 2019 for the communes level (data is taken from the file Table de correspondance code SIREN / Code Insee des communes from https://www.banatic.interieur.gouv.fr/V5/fichiers-en-telechargement/fichiers-telech.php ), by default it imports the latest available one)
warning: The epci level only works for the current year (data is taken from https://www.data.gouv.fr/fr/datasets/base-nationale-sur-les-intercommunalites/ )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_francedata-0.16.2.tar.gz
.
File metadata
- Download URL: django_francedata-0.16.2.tar.gz
- Upload date:
- Size: 65.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e1c3c0ad492631ad6b3e9fe487ec99cc81fe065b20c1d96b82bfbaf331d970 |
|
MD5 | 1d412320fe504df01e2642fd3367e74b |
|
BLAKE2b-256 | fc8ea12f2762be8578d62adae22af9159feaf3efc3acf29038043f429e8c2ce0 |
File details
Details for the file django_francedata-0.16.2-py3-none-any.whl
.
File metadata
- Download URL: django_francedata-0.16.2-py3-none-any.whl
- Upload date:
- Size: 89.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9584745544679a94fbc60e120f770fef1dc5522e1cfaf779e9da5e5c6298115f |
|
MD5 | 8a378213f0a43defc6b7f01942220cea |
|
BLAKE2b-256 | 3ba15b11971a51978b53dae3e4c3e693492ff482d73091fa2af4df2524f45ab1 |