尽管可通过get queryset来过滤,但可利用
可设置项目通用filter
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',)
}
也可在view中指定了filter_backends
class JobListAPIView(ListAPIView):
serializer_class = JobSerializer
queryset = WorkopolisJob.objects.all()
filter_backends = [django_filters.rest_framework.DjangoFilterBackend]
filter_fields = ('industry', 'type', 'location')
网友评论