Setup your GeoDjango application

The Django framework integrates extensions to handle geospatial data. To setup an application which is using such extensions, a bit of work is required:

  • PostgreSQL with PostGIS extension
  • Geospatial libraries

Enable PostgreSQL PostGIS Extension

PostgreSQL includes several extensions. PostGIS is an extension to handle geospatial data. After adding a PostgreSQL database to your application, you can enable the PostGIS extension with:

$ scalingo --app my-app pgsql-console

Next step is to install the libraries Django requires to manipulate these data.

Install Geospatial Libraries

These libraries are proj, geos and gdal. Considering that they are not used commonly, they are not included in our default environment so you need to install them at deployment time.

Usage of the geo-buildpack

To deploy an application with these libraries you need to use an additional buildpack along with the default Python buildpack.

Create a .buildpacks file at the root of your project with the following content to make use of the multi buildpack:

Deploy your application

git add .buildpacks
git commit -m "Use geo-buildpack as long as python-buildpack"
git push scalingo master

Then you’ll see in your deployment output:

=====> Downloading Buildpack:
=====> Detected Framework: geos/gdal/proj
       Using geos version: 3.4.2
       Using gdal version: 1.11.1
       Using proj version: 4.8.0_1

mode_edit Suggest edits