2012-10-29 3 views
5

J'utilise geoDjango. J'ai installé les paquets suivants de la source Gdal, proj1.4, geos3.3.5 et Postgis2.0.1. Je suis un utilisateur d'ubuntu. Lorsque je cours syncdb après cela, je reçois erreur suivante. Est-ce que je manque quelque chose? grâceImpossible d'installer l'index (lié à Geodjango)

Superuser created successfully. 
Installing custom SQL ... 
Installing indexes ... 
Failed to install index for cities.City model: operator class "gist_geometry_ops" does not exist for access method "gist" 

Failed to install index for cities.District model: operator class "gist_geometry_ops" does not exist for access method "gist" 

Failed to install index for cities.PostalCodeCA model: operator class "gist_geometry_ops" does not exist for access method "gist" 

Installed 0 object(s) from 0 fixture(s) 

Répondre

2

vous devez créer un modèle de PostGIS et charger le relevent postgis.sql

que votre chemin de PostGIS est /usr/share/postgresql/8.4/contrib cette course

 

POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib 
sudo -u postgres createdb -E UTF8 template_postgis1 # Create the template spatial database. 
sudo -u postgres createlang -d template_postgis1 plpgsql # Adding PLPGSQL language support. 
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis1';" 
sudo -u postgres psql -d template_postgis1 -f $POSTGIS_SQL_PATH/postgis.sql # Loading the PostGIS SQL routines 
sudo -u postgres psql -d template_postgis1 -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql 
sudo -u postgres psql -d template_postgis1 -c "GRANT ALL ON geometry_columns TO PUBLIC;" # Enabling users to alter spatial tables. 
sudo -u postgres psql -d template_postgis1 -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" 



votre base de données doit ensuite être créée avec le modèle templete créé

 
sudo -u postgres createdb database_name -T template_postgis1 
+0

merci pour votre réponse. J'ai changé le 'POSTGIS_SQL_PATH '. Mais je deviens même. X- ( – Kulbir

+3

'Postgis2.0.1' n'est pas supporté par' django1.4', je suis passé à 'Postgis1.5' et exécute vos commandes, et cela a fonctionné Merci pour votre aide – Kulbir

+1

Je n'ai pas déclassé, mais plutôt J'ai utilisé le patch de rétrocompatibilité sur template_postgis donné dans la réponse de Jeasoft – BenjaminGolder

8

Peut-être que je suis un peu en retard mais je résolu ce problème (Django 1.4.x, PostGIS 2.0.1 et PostgreSQL 9.2) la création d'une classe d'opérateur dans la base de données template_postgis comme ceci:

CREATE OPERATOR CLASS gist_geometry_ops 
FOR TYPE geometry USING GIST AS 
STORAGE box2df, 
OPERATOR  1  << , 
OPERATOR  2  &< , 
OPERATOR  3  && , 
OPERATOR  4  &> , 
OPERATOR  5  >> , 
OPERATOR  6  ~= , 
OPERATOR  7  ~ , 
OPERATOR  8  @ , 
OPERATOR  9  &<| , 
OPERATOR  10  <<| , 
OPERATOR  11  |>> , 
OPERATOR  12  |&> , 

OPERATOR  13  <-> FOR ORDER BY pg_catalog.float_ops, 
OPERATOR  14  <#> FOR ORDER BY pg_catalog.float_ops, 
FUNCTION  8  geometry_gist_distance_2d (internal, geometry, int4), 

FUNCTION  1  geometry_gist_consistent_2d (internal, geometry, int4), 
FUNCTION  2  geometry_gist_union_2d (bytea, internal), 
FUNCTION  3  geometry_gist_compress_2d (internal), 
FUNCTION  4  geometry_gist_decompress_2d (internal), 
FUNCTION  5  geometry_gist_penalty_2d (internal, internal, internal), 
FUNCTION  6  geometry_gist_picksplit_2d (internal, internal), 
FUNCTION  7  geometry_gist_same_2d (geom1 geometry, geom2 geometry, internal); 

Cela a été extrait de cette lien http://trac.osgeo.org/postgis/ticket/1287#comment:8

+0

+1 cela a fonctionné pour moi.J'ai entré psql, suis passé à la base de données postgis_template puis j'ai couru ceci – BenjaminGolder

+0

Merci, j'ai passé plusieurs jours à ce sujet.Un problème vraiment spécifique :) – ismailsunni