Filtering

作者: xncode | 来源:发表于2020-12-11 16:41 被阅读0次

    尽管可通过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')
    

    相关文章

      网友评论

          本文标题:Filtering

          本文链接:https://www.haomeiwen.com/subject/wencpqtx.html