class Feature(models.Model):
shapefile = models.ForeignKey(Shapefile)
id_relat = models.IntegerField(db_index=True)
geom_point = models.PointField(srid=3857, blank=True, null=True)
geom_multipoint = models.MultiPointField(srid=3857, blank=True,
null=True)
geom_multilinestring = models.MultiLineStringField(srid=3857,
blank=True, null=True)
geom_multipolygon = models.MultiPolygonField(srid=3857, blank=True,
null=True)
geom_geometrycollection = models.GeometryCollectionField(srid=3857,
blank=True, null=True)
objects = models.GeoManager()
def __unicode__(self):
return str(self.id)
the error message on syncdb is the following (translated from french to
english):
c:\mygeosite\geodjango>python manage.py syncdb
Syncing...
Creating tables ...
Creating table shapefile_feature
Installing custom SQL ...
Installing indexes ...
Failed to install index for shapefile.Feature model: ERROR: field « geom
_point » of the relation « shapefile_feature already exists
CONTEXT: instruction SQL « ALTER TABLE public.shapefile_feature ADD
COLUMN geo
m_point geometry(Point, 3857) ┬╗
fonction PL/pgsql addgeometrycolumn(character varying,character
varying,characte
r varying,character varying,integer,character varying,integer,boolean),
line 11
0 à instruction EXECUTE
instruction SQL « SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5, $6) »
fonction PL/pgsql addgeometrycolumn(character varying,character
varying,integer,
character varying,integer,boolean), line 5 à instruction SQL
Installed 0 object(s) from 0 fixture(s)
--
Ticket URL: <https://code.djangoproject.com/ticket/21426>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
New description:
def __unicode__(self):
return str(self.id)
}}}
--
Comment:
The traceback is rather difficult to read with all the random unicode
characters but the error basically looks like: 'field "geom_point" of the
relation "shapefile_feature" already exists'.
What GIS database and version are you using?
I wonder if #20968 may be related.
--
Ticket URL: <https://code.djangoproject.com/ticket/21426#comment:1>
Comment (by burton449geo@…):
I use PostGIS 2.1 (PostGres 9.3)
It seems the field geom_point already exists but the error occur when
creating the db on first syncdb. I am sure the table do not exists when
the error occur.
I dont think its its related with ticket
[https://code.djangoproject.com/ticket/20968 #20968], because the problem
there is about spatialite and here it is about PostGIS, but I could be
wrong.
--
Ticket URL: <https://code.djangoproject.com/ticket/21426#comment:2>
Comment (by aaugustin):
I copied your model definition, removed the `ForeignKey(Shapefile)`
because you didn't provides the definition of that model, and syncdb went
through without warnings.
Your problem seems to come from `sql_indexes_for_field`, it's the only
code path in django.contrib.gis that does an ALTER TABLE, and that happens
only under some specific conditions.
Can you confirm that the problem occurs if you start from a blank database
and install just this model with `syncdb`?
--
Ticket URL: <https://code.djangoproject.com/ticket/21426#comment:3>
* status: new => closed
* resolution: => needsinfo
Comment:
Closing as 'needsinfo' for now.
Reopen the ticket if you can provide the information Aymeric specified
because it's needed to reproduce the issue. Also pleae confirm if you
actually are using Django 1.5rc as the version field of the tickets
indicates.
--
Ticket URL: <https://code.djangoproject.com/ticket/21426#comment:4>