I've been using PostGIS via GeoDjango (Django v3.0.7), happily until just now. I have a query (Django .filter()
) that looks like this:
.filter(point__distance_lte=(dlPt, D(m=CloseRadius)))
when it invokes the PostgreSQL query I get this error:
django.db.utils.ProgrammingError: function ST_DistanceSphere(geometry, geometry) does not exist
dlPt
is indeed a Point, <class 'django.contrib.gis.geos.point.Point'>
, and so are the point
attributes in the objects being searched.
Any ideas what the issue might be?
distance_lte
usesST_Distance_Sphere
(note the_
; not sure if typo, though), which is deprecated in PostGIS 3.x. Test with direct SQL; if that's the case, it's tivial to write a wrapper function. Also, if possible, usedwithin
(it calls the index drivenST_DWithin
, which is much faster).