简体   繁体   中英

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM