私は次のモデルを持っています:
class City(models.Model):
name = models.CharField(null=False, blank=False, max_length=200)
coordinates = models.PointField(null=False, blank=False)
objects = models.GeoManager()
以下を使用して、上記の2つの都市間の距離を見つけようとしています:
city1=City.objects.get(name='New York')
city2=City.objects.get(name='Boston')
city1.coordinates.distance(city2)
しかし、次のようになります:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/rok/apps/django-trunk/django/contrib/gis/geos/geometry.py", line 667, in distance
raise TypeError('distance() works only on other GEOS Geometries.')
TypeError: distance() works only on other GEOS Geometries.
構造とデータを見ると、問題ないようです。
>>> city1.coordinates.coords
(40.714623,-74.006605)
>>> city2.coordinates.coords
(42.360024, -71.060168)
私は何を間違っていますか?