Opened 5 years ago

Closed 5 years ago

#21426 closed Uncategorized (needsinfo)

No indexes are created on syncdb

Reported by: burton449geo@… Owned by: nobody
Component: GIS Version: 1.5-rc-2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

the model is the following:

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(

the error message on syncdb is the following (translated from french to english):

c:\mygeosite\geodjango>python syncdb
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)

Change History (4)

comment:1 Changed 5 years ago by Tim Graham

Description: modified (diff)

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.

comment:2 Changed 5 years ago 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 #20968, because the problem there is about spatialite and here it is about PostGIS, but I could be wrong.

comment:3 Changed 5 years ago by Aymeric Augustin

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?

comment:4 Changed 5 years ago by Ramiro Morales

Resolution: needsinfo
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top