【发布时间】:2023-03-04 20:28:01
【问题描述】:
我收到一个错误:The response content must be rendered before it can be iterated over.
下面这行代码有什么问题..??如果有人能弄清楚我在哪里做错了,那将不胜感激。
非常感谢您。
序列化器.py
class GlobalShopSearchList(ListAPIView):
serializer_class = GlobalSearchSerializer
def get_queryset(self):
try:
query = self.request.GET.get('q', None)
print('query', query)
if query:
snippets = ShopOwnerAddress.objects.filter(
Q(user_id__name__iexact=query)|
Q(user_id__mobile_number__iexact=query)|
Q(address_line1__iexact=query)
).distinct()
return Response({'message': 'data retrieved successfully!', 'data':snippets}, status=200)
else:
# some logic....
except KeyError:
# some logic....
【问题讨论】:
标签: python django django-rest-framework