【问题标题】:Getting error with postgis Geodjango on HerokuHeroku 上的 postgis Geodjango 出错
【发布时间】:2016-10-20 12:06:24
【问题描述】:

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 migrate 时,我得到:

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

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

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

【问题讨论】:

标签: django heroku postgis geodjango


【解决方案1】:

我终于有时间回去看看这个了。原来问题是 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 正确导入设置会出现什么问题吗?似乎正确导入了其余设置,而不是数据库设置。

【讨论】:

    猜你喜欢
    • 2015-06-05
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 2021-05-07
    相关资源
    最近更新 更多