我最近将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
有谁知道这里的问题是什么?
谢谢!
答案 0 :(得分:0)
在filter_backends
中,我只需删除filters.DjangoFilterBackend
。现在工作正常。