toastdriven/django-tastypie — pull request #544 by adamhadani (2012-06-26 07:12:35+00:00)
Title: Added support for GeoDjango Distance Query 

I added rudimentary support to GeoDjango Distance Queries (See [here](https://docs.djangoproject.com/en/1.4/ref/contrib/gis/db-api/#distance-queries)) in the tastypie.contrib.gis package.

The usage right now may not be the cleanest but the simplest I could come up with. I would love for any comments/discussion on better ways to achieve this, however for lack of such this did the job for me.

When supplying a distance query parameter (e.g mypointfieldname__distance_lte=), supply two additional query parameters:
distance.radius=
distance.units=

Where distance.units should be one of the values in the enumeration django.contrib.gis.measure.Distance.UNITS (e.g 'mi', 'km')

Example use case assuming your underlying model has a PointField-type field called 'location':

http://local.myapp.com:8000/api/v1/entity/?format=json&location__distance_lte={"type": "Point", "coordinates": [-122.475233, 37.768617]}&distance.radius=12&distance.units=km