问题描述
我正在使用Django 1.2.3,PostGIS 1.5.2。由于某些原因,当我运行
它正在从我的模型创建数据库中的所有其他字段,但避免创建一个应用为PointField的名为point的字段。 p>
在我的models.py文件中,我已经导入:
from django。 contrib.gis.db导入模型
并评论:
#from django.db import models
我的模型看起来像这样:
类MyModel(models.Model):
/ pre>
myid = models.AutoField(primary_key =真的)
title = models.CharField(max_length = 50)
point = models.PointField()
objects = models.GeoManager()
此外,当创建管理端时,我会收到以下错误:
无法安装报告索引.MyModel模型:perm发行被拒绝关系spatial_ref_sys
CONTEXT:SQL语句SELECT SRID FROM spatial_ref_sys WHERE SRID = new_srid
PL / pgSQL函数addgeometrycolumn行74在SQL语句
SQL语句SELECT AddGeometryColumn(' $$ 2 $ 3 $ 4 $ 5
PL / pgSQL函数addgeometrycolumn第4行SQL语句
在我的setting.py中,我添加了:
DATABASES = {
'default':{
'ENGINE':'django.contrib.gis.db.backends.postgis',
和
INSTALLED_APPS =(
...
'django。 contrib.gis',
...
任何iz我为什么要放弃这个问题?谢谢!
解决方案问题是PostgreSQL用户角色django正在使用的权限不足。
当我使用PostGIS启用数据库时,使用不同的用户角色创建了几个表geometry_columns和spatial_ref_sys,发生了什么。所以Django试图访问这两个表时,因为没有足够的权限,所以再次。
这是那么简单,呃:)
I'm using Django 1.2.3, PostGIS 1.5.2.
For some reason when I run
it's creating all the other fields in the database from my models but avoids creating a field I named point that supposed to be a PointField.
In my model.py files I have imported:
from django.contrib.gis.db import models
and commented:
#from django.db import models
my model looks something like this:
class MyModel(models.Model): myid = models.AutoField(primary_key=True) title = models.CharField(max_length=50) point = models.PointField() objects = models.GeoManager()
Also when is creating the admin side I get the errors below:
Failed to install index for reports.MyModel model: permission denied for relation spatial_ref_sys CONTEXT: SQL statement "SELECT SRID FROM spatial_ref_sys WHERE SRID = new_srid" PL/pgSQL function "addgeometrycolumn" line 74 at SQL statement SQL statement "SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5)" PL/pgSQL function "addgeometrycolumn" line 4 at SQL statement
In my setting.py I've added:
DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis',
and
INSTALLED_APPS = ( ... 'django.contrib.gis', ...
Any ides why I'm heaving this issues? Thank you!
解决方案The problem was that the PostgreSQL user role django was using had insufficient rights.
What happened when I enabled my database with the PostGIS it created a couple of tables "geometry_columns" and "spatial_ref_sys" using a different user role. So again when Django was trying to access those two tables it chocked because it didn't have enough rights.
It was that simple, whew :)
这篇关于当我运行python manage.py syncdb时,Django避免在数据库中创建PointField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!