queryset = MyModel.objects.all()
def get_queryset(self):
if not self.request:
return MyModel.objects.none()
if self.request.query_params:
queryset = self.filter_queryset(self.queryset)
else:
queryset = self.queryset
# ... the rest of the method code ...
return queryset
需要修改 queyset的时候, 都要这样改,不然会报 和 docs 不兼容