在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')