Hard time figuring out how to use DistanceToPointFilter

128 views
Skip to first unread message

Hesam Dadafarin

unread,
Dec 14, 2015, 7:37:16 PM12/14/15
to Django REST Framework GIS
Hi All,
We are very new to whole django GIS and we have hard time implement our filter for a model viewset:

class GeoModelViewSet(viewsets.ModelViewSet):
   queryset = Geo.objects.all()
   serializer_class = GeoSerializerSmall
   distance_filter_field = 'location'
   filter_backend = (DistanceToPointFilter, )

def list(self, request):
queryset = Geo.objects.all()
queryset = GeoFilter(request.GET, queryset=queryset)
serializer = NDTSerializerSmall(queryset, many=True)
return Response(serializer.data)


Although the example on the documentation look very simple, but we don't have any clue how we should modify our view or seriallizer to get this working. We even checked the filter.py on Github and it made sense to us how you have imeplemented the distance filter but we don't know the exact syntax of applying the filter to our data.

Thanks for you help.



Nemesis

unread,
Dec 15, 2015, 5:09:33 AM12/15/15
to django-rest-...@googlegroups.com
Hi Hesam,

since this was a contribution to DRF-gis, I do not know a lot more than you do.

I can suggest you to look at the official DRF documentation for filter and filtersets and study the test project in the DRF-gis repository more closely.

Federico
--
You received this message because you are subscribed to the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Federico Capoano

unread,
Apr 18, 2016, 5:49:31 AM4/18/16
to Django REST Framework GIS
Hi Hesam,

you may ask on stackoverflow.com and use the new django-rest-framework-gis tag. This should help you more than what I could.

Federico
Reply all
Reply to author
Forward
0 new messages