Tyler
Tyler

Reputation: 2386

heroku postgis makemigrations error geodjango

So I have multi build pack installed for my build pack for heroku

https://github.com/ddollar/heroku-buildpack-multi.git

and I have the .buildpacks file

https://github.com/cyberdelia/heroku-geo-buildpack.git#1.3
https://github.com/heroku/heroku-buildpack-python

The installation works but when I run python manage.py makemigrations I get this error:

django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version 
for database "d34ce1ddsg9nkp". GeoDjango requires at least PostGIS version 1.3. 
Was the database created from a spatial database template?

I have tried multiple ways of setting the database in settings.py such as:

        GEOS_LIBRARY_PATH = environ.get('GEOS_LIBRARY_PATH')
        GDAL_LIBRARY_PATH = environ.get('GDAL_LIBRARY_PATH')
and
        GEOS_LIBRARY_PATH = "{}/libgeos_c.so".format(environ.get('GEOS_LIBRARY_PATH'))
        GDAL_LIBRARY_PATH = "{}/libgdal.so".format(environ.get('GDAL_LIBRARY_PATH'))

What am I doing wrong?

Upvotes: 0

Views: 165

Answers (1)

Tyler
Tyler

Reputation: 2386

Ok so I fixed this by enabling postgis on heroku by running these commands

heroku pg:psql
create extension postgis;

then I ran this command to see what version i had on heroku

SELECT PostGIS_full_version();

then I put this is my settings.py file

POSTGIS_VERSION = (2, 1, 5)

and viola it works!

Upvotes: 1

Related Questions