2011-05-19 3 views
3

J'essaie de faire fonctionner GeoDjango sur SpatiaLite sous Ubuntu 11.04, et même avec une configuration minimale, je rencontre une erreur étrange. Enregistrement d'une instance d'un modèle avec géo-champs travaux, mais le chargement échoue à nouveau avec un exception:Erreur lors de l'utilisation de GeoDjango avec SpatiaLite sur Ubuntu

Error encountered checking Geometry returned from GEOS C function "GEOSWKBReader_read_r". 

parties pertinentes de mon settings.py

DATABASES = { 
    'default': { 
    'ENGINE': 'django.contrib.gis.db.backends.spatialite', 
     'NAME': '/tmp/test.db', 
    } 
} 

INSTALLED_APPS = (
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'django.contrib.messages', 
    'django.contrib.admin', 
    'django.contrib.gis', 
    'testapp', 
) 

testapp.models:

from django.contrib.gis.db import models 

class TestModel(models.Model): 
    name = models.CharField(max_length=10) 
    location = models.PointField() 

testapp.admin

from django.contrib.gis import admin 

from testapp.models import TestModel 

admin.site.register(TestModel, admin.OSMGeoAdmin) 

/edit: le même code fonctionne sans problème sur PostgreSQL/PostGIS

Répondre

5

OK, je me suis trouvé le problème: j'ai oublié d'utiliser models.GeoManager comme gestionnaire par défaut. Cela résout mon problème:

class TestModel(models.Model): 
    name = models.CharField(max_length=10) 
    location = models.PointField() 

    objects = models.GeoManager() 
Questions connexes