Apps and custom webservices from SITN. This app can run in two different contexts: internet or intranet. Depending on the context, some apps will not be installed when deploying.
- PostgreSQL >= 11 + PostGIS
- Python >= 3.10
- GDAL, GEOS (if running without docker on Windows, install OSGEO4W and add its bin directory to the Path)
- GNU gettext https://www.gnu.org/software/gettext/
Fork and clone this repository. Make a copy of the .env.sample file and adapt it to your environment settings:
cp .env.sample .env
and configure the different variables.
The paths related to GDAL et GEOS can either point to existing installations on the system, e.g.:
# Path to the folder containing all GDAL/GEOS DLLs
GDAL_PATH="C:/Program Files/GDAL/"
# Full path to the GDAL DLL
GDAL_LIBRARY_PATH="C:/Program Files/GDAL/gdal.dll"
# Full path to GEOS C API DLL
GEOS_LIBRARY_PATH="C:/Program Files/PostgreSQL/16/bin/libgeos_c.dll"
Alternatively, you can install GDAL (and its GEOS and PROJ dependencies), using the geospatial python wheels provided here:
Download the appropriate version, then install it in the venv using pip, e.g.:
pip install .\gdal-3.11.4-cp314-cp314-win_amd64.whlThen configure the GDAL paths in the .env file to point to the ressources in the venv, e.g.:
# Path to the folder containing all GDAL/GEOS DLLs
GDAL_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/"
# Full path to the GDAL DLL
GDAL_LIBRARY_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/gdal.dll"
# Full path to GEOS C API DLL
GEOS_LIBRARY_PATH="C:/Projects/sitn_applications/venv/Lib/site-packages/osgeo/geos_c.dll"
You should also have PostgreSQL with PostGIS installed, and the path to PostgreSQL's bin directory should be defined in the Path variable in your Windows system environment variables (e.g. C:\Program Files\PostgreSQL\18\bin).
Finally, you need to have gettext installed:
First, create a copy of the .env.sample file called .env:
cp .env.sample .env
Install and activate the virtual environment:
python -m venv venv
./venv/Scripts/activate
python -m pip install --upgrade pip
pip install -r requirements-lock.txtCreate a local database:
python manage.py createdbRun migrations
python manage.py migrateDump some fresh data from prod database
python manage.py getdataYou might want to create an admin user:
python manage.py createsuperuserYou're now ready to go:
python manage.py collectstatic
python manage.py compilemessages --locale=fr
python manage.py runserverIf developping on the Internet instance, then you should define a new environment variable
in the .env.dev. file:
IS_INTRANET=False
First, create a copy of the env.sample file called env.<context>.local:
cp .env.sample .env.intranet.local
Then you'll be able to deploy locally on docker:
python deploy intranet local
Deployments are based on shared .env files. If your project requires migrations, the default user will not be able to create tables, so you must temporarily switch to a more privileged user.
Then you'll be able to deploy your instance with python deploy <context> <instance>
Example:
python deploy intranet prepub
Running tests will require a database for testing.
python manage.py testdbthen you can run tests
python manage.py test --keepdbPrepare translation files
django-admin makemessages -l frthen compile them
python manage.py compilemessages --locale=frpython manage.py startapp myappThen:
- Put something in
urls.pyin your app folder - Import your urls in
sitn/urls.py - Install the app in
settings.py
In your venv:
- Update the versions manually in requirements.in
pip-compile requirements.in --output-file=requirements-lock.txtpip install -r requirements-lock.txt