I've created a Django project, using a PostGIS backend, which all seems well as far as I can tell. I've now created an app in this project as follows:
from django.contrib.gis.db import models
class MyPlace(models.Model):
name = models.CharField(max_length=255)
location = models.PointField()
objects = models.GeoManager()
This should be a simple model for a name/point pair (to be built upon later), but the database is not creating the location field. There is no error, and the field is ignored until I try to access the model (using the Admin) where it croaks with "DatabaseError: column myproj_myplace.location does not exist"
I'm really not sure what's going wrong here, since there is no error on parsing (syncdb works without exception). When I ran the sql command for the model, this is what I got:
BEGIN;
CREATE TABLE "myproj_myplace" (
"id" serial NOT NULL PRIMARY KEY,
"name" varchar(255) NOT NULL
)
;
COMMIT;
Again no fields! Any ideas?
I have both 'django.contrib.gis' and my app in my INSTALLED_APPS, and have built my database schema with PostGIS support (adding the sql functions file method, not the template method)
Cheers in advance for any assistance
This is done from an empty schema, and the table is created from scratch
Try 'python manage.py sqlall {app}', the sql output doesn't include spatial columns for some reason but sqlall does. Then try running the output directly on the database using pgadmin3, you'll likely get a clearer idea of what's going wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With