在 Heroku 上部署 GeoDjango 应用程序时出现问题
Problems deploying GeoDjango application on Heroku
我在 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;
已配置的构建包:
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
我已阅读的参考资料:
我想不出解决办法,
在此先感谢您的帮助。
您需要在您的 heroku 实例中安装 GDAL
。
这是 heroku 的构建包
一个朋友在其他论坛帮助我,他告诉我将 heroku 上的 buildpack url 更改为:
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')
解决了部署应用程序的问题。
谢谢。
我在 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;
已配置的构建包:
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
我已阅读的参考资料:
我想不出解决办法,
在此先感谢您的帮助。
您需要在您的 heroku 实例中安装 GDAL
。
这是 heroku 的构建包
一个朋友在其他论坛帮助我,他告诉我将 heroku 上的 buildpack url 更改为:
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')
解决了部署应用程序的问题。
谢谢。