Groups
Groups
Sign in
Groups
Groups
Django REST Framework GIS
Conversations
About
Send feedback
Help
Order results by distance
72 views
Skip to first unread message
Dmitry Semenov
unread,
Sep 2, 2015, 1:20:19 PM
9/2/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django REST Framework GIS
hi Guys,
there is a filter by distance
https://github.com/djangonauts/django-rest-framework-gis#distancetopointfilter
but how do I get results sorted (ordering=?) by distance ASC or DESC?
thanks
Federico Capoano
unread,
Sep 9, 2015, 5:23:12 AM
9/9/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django REST Framework GIS
The code of the filter is here:
https://github.com/djangonauts/django-rest-framework-gis/blob/master/rest_framework_gis/filters.py#L154-L177
It seems it uses the "dwithin" filter lookup:
https://docs.djangoproject.com/en/1.8/ref/contrib/gis/geoquerysets/#dwithin
A quick Google search returned this thread on the geodjango mailing list:
https://groups.google.com/forum/#!topic/geodjango/In-5t_SngB4
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):
subclass
DistanceToPointFilter
in your project, implement what you need and share the code here
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