Hi Stackoverflow people,
In the past, I always developed my Django projects locally with sqlite as database platform. Now, I wanted to move to PostgreSQL to take advantage of GIS features, but the transition gives me huge grief.
I have installed postgresql similar to this post and then followed the GeoDjango description for the creation of the database.
Furthermore, I replaced the models class by
from django.contrib.gis.db import models
and add
geolocation = models.PointField(_('Geo Location'),
geography=True,
help_text=_('Geolocation with Longitude and Latitude'))
objects = models.GeoManager()
Now, before diving deeper into the postgreSQL sphere, I wanted to test the model access through the Django Admin, and I encountered the first error.
When I select the model (which i just modified as mentioned above) in the Admin, I get the following error:
**InternalError at /admin/remap/project/**
current transaction is aborted, commands ignored until end of transaction block
This error is connected with a wrong sql query, but I am surprised that the Django Admin creates wrong sql statements (used by million developers and it worked fine in the earlier sqlite config).
When I check the django sql statement, I can see the entry for the PointField
"geolocation" geography(POINT,4326) NOT NULL,
but when I check psql \d projects, I can't see the change to the PointField (this is what should cause the error). Since I am using South, I executed
./manage.py schemamigration projects --initial
./manage.py migrate projects
but I get the message
Running migrations for projects:
- Nothing to migrate.
- Loading initial data for projects.
How can I convince south / postgresql that there is something to migrate? Do you see any other problem with the transition form SQLite to PostgreSQL?
Thank you for your answer & help!
A possible answer:
Did you syncdb? Often when I'm having trouble with south, I just delete the database and run manage.py syncdb
from scratch to make sure all my columns are in line. If you want south to ignore migration-enabled apps and just syncdb up to the current version, you can use manage.py syncdb --all