我在heroku上部署我的GeoDjango应用程序时遇到了麻烦(使用Free Dyno,但如果有必要,我可以更改)。当我执行push heroku master --force
时,我收到以下错误:
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: cannot import name 'GDALRaster'
我已经安装了postgis:
$ heroku pg:psql
create extension postgis;
已配置的buildpacks:
heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
Created .buildpacks file at my project with this links:
https://github.com/cyberdelia/heroku-geo-buildpack.git#1.1
https://github.com/heroku/heroku-buildpack-python.git#v29
Updated Procfile:
web: python manage.py collectstatic --noinput; gunicorn projectname.wsgi
我的 settings.py 已配置:
INSTALLED_APPS = [
....
'django.contrib.gis',
]
default_dburl = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')
DATABASES = {
'default': config('DATABASE_URL', default=default_dburl, cast=dburl),
}
DATABASES['default']['ENGINE'] = config('DB_ENGINE')
我的DB_ENGINE位于.env文件:
DB_ENGINE=django.contrib.gis.db.backends.postgis
我已经读过的参考文献:
我无法找到解决方案,
提前感谢您的帮助。
答案 0 :(得分:1)
答案 1 :(得分:1)
一位朋友在其他论坛帮助过我,他告诉我将heroku上的buildpack网址更改为:
git://github.com/dulaccc/heroku-buildpack-geodjango.git#1.1
我将这些行添加到 settings.py :
GEOS_LIBRARY_PATH = environ.get('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = environ.get('GDAL_LIBRARY_PATH')
它解决了部署应用程序的问题。
感谢。