在 Heroku 上使用 postgis Geodjango 出错

Getting error with postgis Geodjango on Heroku

已安装 Postgis 扩展:

 :DATABASE=> SELECT postgis_version();                                         
        postgis_version            

 2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

我有以下构建包:

  1. https://github.com/cyberdelia/heroku-geo-buildpack.git
  2. https://github.com/heroku/heroku-buildpack-python.git

当我 运行 manage.py 迁移时,我得到:

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

我正在使用现在支持 postgis 的爱好 deb postgres https://devcenter.heroku.com/changelog-items/792

我是否需要安装不同的构建包或添加一些额外的配置?一切都在本地使用 postgis。

我终于有时间回去看看这个了。原来问题是 Heroku 没有正确导入我的设置。我正在使用 cookiecutter-django 设置方案将通用设置导入到生产中,但由于某种原因 Heroku 没有按预期工作。

我的常用设置包含:

DATABASES['default']['ATOMIC_REQUESTS'] = True
DATABASES['default']['ENGINE'] = "django.contrib.gis.db.backends.postgis"

我的作品包含:

DATABASES['default'] = env.db("DATABASE_URL")

Heroku 没有导入那些常用设置。当我在 heroku 中检查 django shell 时,生产设置有

 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ATOMIC_REQUESTS': False

将 DATABASES['default']['ENGINE'] = "django.contrib.gis.db.backends.postgis" 添加到生产设置后一切正常。

有人知道从 common.py 正确导入设置会出现什么问题吗?似乎正确导入了其余设置,而不是数据库设置。