django 批量查询

 view视图

def list(self, request, *args, **kwargs):
	"""获取消息列表"""
	id_list=[1,4,5]
	queryset = models.Test.objects.in_bulk(id_list)
	ser = self.serializer_class(instance=queryset.values(), many=True)
	return Response(ser.data)

 

你可能感兴趣的:(Django,django)