[GIS] Spatialite in GeoDjango – “…they do not properly define db_type…”

geodjangopythonspatialite

I've started a new project and choose GeoDjango for it. Because I already developed with Django and sqlite as a DBMS and all worked perfectly fine for me, I found it a great option to use spatialite to make the first development steps and perhaps switch to PostGIS later on, when the app needs scaling.

Although the docs tell different I faced a couple of problems now bringing the spatialite datastore up to life.

First I created a new empty sqlite database file on the sqlite command line (because let django do that for me with syncdb resulted in an error where syncdb didn't hae the geometry_columns table to register my spatial table…so it's about creating the spatial repository first).

Second I ran spatialite database.db "SELECT InitSpatialMetaData();" to create the repository tables.

At least I ran python manage.py syncdb to create my model tables. It does a couple of thing, but ends up in the following error:

Operations to perform:
Synchronize unmigrated apps: gis
Apply all migrations: admin, contenttypes, walmap, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
Applying walmap.0001_initial... OK
Applying walmap.0002_campsite_capacity...AddGeometryColumn: "duplicate column name: point"
OK
Applying walmap.0003_auto_20141126_1434...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
  :
  :
File "/home/juergen/Development/wal/env/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 460, in alter_field
new_field,
ValueError: Cannot alter field walmap.Campsite.point into walmap.Campsite.point - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)

The model class just consists of an id field, a name, a slug, a Point Geometry and an int field for capacity, so nothing special here.

Any ideas about this issue?

EDIT:
SpatialLite is version 4.1.1

PROJ.4 is version 4.8.0

GEOS is version 3.4.2

Django version 1.7

python version 2.7.6

Best Answer

seems that anything in the migrations went wrong....I deleted the complete migrations folder from the django app, recreated the database and syncdb'ed then. et voilá, now it works. Another day of gray hair for nothing ;)

Related Question