Skip to content

Adding postgis support

Saurabh edited this page Jun 8, 2015 · 3 revisions

Setup

Add django.contrib.gis to INSTALLED_APPS:

INSTALLED_APPS = (
  ...
  'django.contrib.gis',  # https://docs.djangoproject.com/en/1.8/ref/contrib/gis/install/
  ...
)

Add 4326 as the DEFAULT_SRID in your settings:

# DJANGO GIS
DEFAULT_SRID = 4326

The POSTGIS support on heroku is not available on hobby version of postgres databases, and the support is in beta. To add postgis support on Heroku, run the following heroku commands:

heroku buildpacks:add "https://github.com/cyberdelia/heroku-geo-buildpack.git#1.3" --app=<heroku-app-name>
heroku addons:add heroku-postgresql:standard-0 --app=<heroku-app-name>
heroku pg:psql DATABASE_URL -c "CREATE EXTENSION postgis;" --app=<heroku-app-name>
heroku config:set DATABASE_URL=`heroku config:get 'DATABASE_URL' --app=<heroku-app-name> | sed 's/postgres/postgis/'` --app=<heroku-app-name>

References

Clone this wiki locally