I’m using PostGIS with django. I know how to add a “POINT” on PostgreSQL from decimal coordinates but how do I add it using GeoDjango?
This is how I do it in PostgreSQL:
UPDATE "my_table" SET coordinates=GeometryFromText('POINT(-93.7505 31.3059)',4269) WHERE id=101;
How do I do the same thing from django?
Here’s what I think you’re asking for:
GeoDjango uses an object relational mapper. In your models.py, you’ll have to define a model that includes a point, e.g:
Then, in one of your views, you’ll need to instantiate a my_points object:
I imagine this isn’t syntactically perfect, but the GeoDjango model api: http://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/ and the regular geodjango models guide: http://docs.djangoproject.com/en/dev/topics/db/models/ will probably get you where you need to go. Hope that helps.
Edit:
Okay, I didn’t understand your post. “add a POINT” indicated to me that you wanted to add one. Your SQL statement is for updating a value, though.
To update values in a database, you’ll still need a model. I’m going to proceed on the assumption that you have a model set up called “my_points”.