简体   繁体   English

heroku postgis makemigrations错误geodjango

[英]heroku postgis makemigrations error geodjango

So I have multi build pack installed for my build pack for heroku 所以我为heroku的构建包安装了多个构建包

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

and I have the .buildpacks file 我有.buildpacks文件

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: 安装工作正常,但是当我运行python manage.py makemigrations时,出现此错误:

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: 我尝试了在settings.py中设置数据库的多种方法,例如:

        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上启用postgis来解决此问题

heroku pg:psql
create extension postgis;

then I ran this command to see what version i had on heroku 然后我运行此命令以查看我在heroku上拥有的版本

SELECT PostGIS_full_version();

then I put this is my settings.py file 然后我把这是我的settings.py文件

POSTGIS_VERSION = (2, 1, 5)

and viola it works! 和中提琴奏效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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