Forums

GeoDjango/PostGIS distance lookup not working

I'm building an api to make distance lookups using Django 1.8, GeoDjango, Django REST Framework and PostGIS.

Locally I'm using PostGIS 2.1.7, PA uses 2.1.4... I'm not able to install an earlier version locally (not so strong with making and installing).

The problem is that locally an api request like http://localhost:8000/v1/test-entries/8.5513076999999988%2055.6684179999999955/ return nothing, as it should. But doing the same request (using the same coordinates) on the live version on PA return all entries in the DB. The code is the same both locally and on PA. The distance lookup code is like so:

return TestEntry.objects.filter(pnt__distance_lte=(pnt, 10))

The only difference I see is the PostGIS version, but it seems unlikely that such a basic functionality shouldn't work in an older version.

Does anyone have experience with these kinds of technologies and give me some hints to what could be wrong?

I'm not an expert either but I agree that it would be really weird for such basic functionality to work in one version and not in another. Perhaps someone on the PostGIS IRC channel or mailing lists (links here) could help?

So basically the issue was that I had unapplied migrations... I came to his realisation thanks to a users comment here http://gis.stackexchange.com/questions/159429/geodjango-postgis-distance-lookup-not-working?noredirect=1#comment236082_159429.

glad you figured it out! :)