I have the following model:
class City(models.Model): name = models.CharField(null=False, blank=False, max_length=200) coordinates = models.PointField(null=False, blank=False) objects = models.GeoManager()
I am trying to find the distance between two cities using the following:
city1=City.objects.get(name='New York') city2=City.objects.get(name='Boston') city1.coordinates.distance(city2)
But having received the following:
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.
Looking at the structures and data, it looks fine:
>>> city1.coordinates.coords (40.714623,-74.006605) >>> city2.coordinates.coords (42.360024, -71.060168)
What am I doing wrong?
source share