1

我最近将 Django Rest Framework 更新到了 3.3.1 版。这样做后,我收到以下错误:Failed lookup for key [form] in u'None'

当我访问这个视图时它就来了:

class SearchListAPIView(generics.ListAPIView):
    serializer_class = SearchMyUserSerializer
    filter_backends = (
        filters.DjangoFilterBackend,
        filters.SearchFilter,
        filters.OrderingFilter,
    )
    search_fields = ('^username', '^full_name',)

    def get_queryset(self):
        queryset = MyUser.objects.all()
        username = self.request.query_params.get('username', None)
        full_name = self.request.query_params.get('full_name', None)

        if username and full_name is not None:
            queryset = queryset.filter(username=username, full_name=full_name)
        elif username is not None:
            queryset = queryset.filter(username=username)
        elif full_name is not None:
            queryset = queryset.filter(full_name=full_name)
        return queryset

有谁知道这里的问题是什么?

谢谢!

4

1 回答 1

0

在 中filter_backends,我只需要删除filters.DjangoFilterBackend. 它现在工作正常。

于 2015-12-07T20:38:13.507 回答