我需要在一个列表方法中传递两个查询集,我想要这样的东西......
def list(self,request):
queryset1 = Algorithm1.objects.all()
serializer1 = Algorithm1Serializer(queryset,many=True)
queryset2 = Algorithm2.objects.all()
serializer2 = Algorithm2Serializer(queryset,many=True)
return Response(serializer.data)
如何实现?事先提前
答案 0 :(得分:3)
你可以创建一个新词典
result = {'serializer1': serializer1.data, 'serializer2': serializer2.data}
return response(result)