djangorestframework-gis按距离指示

时间:2016-01-25 19:31:55

标签: django-rest-framework gis geodjango

djangorestframework-gis中,存在DistanceToPointFilter,它返回距给定点一定距离内的结果。然后,如何在不重复任何距离计算的情况下按距离该点排序结果?

这就是我目前的DRF视图:

class PlaceList(generics.ListAPIView):
    queryset = Place.objects.filter(active=True)
    serializer_class = ListSerializer
    distance_filter_field = 'address.geometry'
    filter_backends = (filters.DjangoFilterBackend, DistanceToPointFilter)
    filter_class = PlaceFilter
    ordering_fields = ('area', 'year_completed')

0 个答案:

没有答案