Order results by distance

72 views
Skip to first unread message

Dmitry Semenov

unread,
Sep 2, 2015, 1:20:19 PM9/2/15
to Django REST Framework GIS
hi Guys,

there is a filter by distance
but how do I get results sorted (ordering=?) by distance ASC or DESC?

thanks


Federico Capoano

unread,
Sep 9, 2015, 5:23:12 AM9/9/15
to Django REST Framework GIS
The code of the filter is here:

It seems it uses the "dwithin" filter lookup:

A quick Google search returned this thread on the geodjango mailing list:

It seems what you want to do is possible but not implemented.

You have mainly two options (and can even do both if you want):
  1. subclass DistanceToPointFilter in your project, implement what you need and share the code here
  2. add the possibility to do what you want in drf-gis and submit a patch, this requires adding a test for the new case
Federico
Reply all
Reply to author
Forward
0 new messages