我正在尝试设置 GeoDjango 应用程序来测试 an earlier problem我有。我已经设置了一个 postgresql 数据库,创建了一个新的 Django 项目和应用程序,但是当我尝试 ./manage.py syncdb
时,我得到了这个:
django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "django_geotest". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template?
我不明白,因为我之前已经完成了 GeoDjango 要求的所有安装,并通过这样做创建了这个 django_geotest
数据库:
$ createdb -T template_postgis django_geotest
看起来数据库设置正确:
django_geotest=# SELECT PostGIS_full_version();
postgis_full_version
-------------------------------------------------------------------------------------------------------
POSTGIS="1.5.3" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.3" USE_STATS
(1 row)
描述数据库,我得到这个:
django_geotest=# \d
List of relations
Schema | Name | Type | Owner
--------+-------------------+-------+-------
public | geography_columns | view | phil
public | geometry_columns | table | phil
public | spatial_ref_sys | table | phil
(3 rows)
所以现在我不知道接下来要尝试什么......我对 postgresql 及其模板等的了解不是那么好。有任何想法吗?谢谢。
最佳答案
我在使用自制软件安装在 OS X 10.9.1 上的 PostgreSQL 9.3 和 PostGIS 2.1 时遇到了同样的问题。
对于这个特定的问题,你只需要添加这一行:
POSTGIS_VERSION = ( 2, 1 )
将您的 PostGIS 版本的逗号分隔编号用于 settings.py
。
我不确定为什么,但 Django 无法从 PostGIS 读取版本信息。
关于django - 我的 PostGIS 数据库看起来不错,但 GeoDjango 不这么认为……为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10584852/