这就是我想你问:
GeoDjango内置使用对象关系映射。在你的models.py,你必须定义一个模型,其中包括点,例如:在你的视图之一
class my_points(models.Model):
name = models.CharField(max_length = 100)
coords = models.PointField()
然后,你需要实例化一个对象my_points:
a = my_point(name="example", coords=x,y)
我想这不是语法上的完美,但GeoDjango模型API:http://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/和常规geodjango模型指南:http://docs.djangoproject.com/en/dev/topics/db/models/可能会让你到你需要去的地方。希望有所帮助。
编辑: 好吧,我不明白你的帖子。 “添加一个点”表示你想添加一个。不过,您的SQL语句用于更新值。
要更新数据库中的值,您仍然需要一个模型。我将继续假设你有一个名为“my_points”的模型。
from django.contrib.gis.geos import GEOSGeometry
# queries the database for the object with an id=101
a = my_points.objects.get(id=101)
# defines your point
pnt = GEOSGeometry('POINT(5 23)')
# updates the object in memory
a.coords = pnt
# saves the changes to the database
a.save()
使用GeoDjango我想要对具有POINT几何字段的表执行更新查询。 – avatar 2011-02-25 19:58:47
真的不知道SO的工作原理。不过,更新了我的帖子。希望这更有用 – canisrufus 2011-02-25 20:39:22