Mat*_*pel 27 django postgresql postgis geodjango
我正在尝试推出GeoDjango应用.我在Lion上使用brew安装了Postgres和PostGIS.我创建使用template_postgis数据库:createdb -T template_postgis test.
当我运行时python manage.py syncdb,我收到以下错误:
django.core.exceptions.ImproperlyConfigured:无法确定数据库"test"的PostGIS版本.GeoDjango至少需要PostGIS 1.3版.是否从空间数据库模板创建了数据库?
如何追踪错误来源?我已经检查过用户和传递配置是否可以访问数据库等.
Dav*_*vid 40
只需添加您的settings.py正确版本的postgis:
POSTGIS_VERSION =(2,0,3)
ivy*_*ivy 19
作为第一个调试步骤:尝试手动检查postgis模板版本,例如在命令行上连接到您的数据库psql test,然后查询select postgis_lib_version();.此函数应在template_postgis中定义并返回一些数字.示例输出:
$ psql test
psql (9.0.4)
Type "help" for help.
test=# select postgis_lib_version();
postgis_lib_version
---------------------
1.5.2
(1 row)
Run Code Online (Sandbox Code Playgroud)
如果发生错误,您就知道错误发生在数据库中.
Zag*_*ags 10
我的解决方案是在postgres终端中运行以下命令:
psql database_name
database_name=# CREATE EXTENSION postgis;
Run Code Online (Sandbox Code Playgroud)
如果你得到ERROR: relation "spatial_ref_sys" already exists,请运行以下内容CREATE EXTENSION postgis:
drop table spatial_ref_sys;
drop table geometry_columns;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10775 次 |
| 最近记录: |