2015-09-22 50 views

回答

0

您可以覆蓋視圖中的list()方法以獲得所需的響應。

class MyView(..): 

    def list(self, request, *args, **kwargs): 
     queryset = self.filter_queryset(self.get_queryset()) 
     serializer = self.get_serializer(queryset, many=True) 
     serializer_data = serializer.data # get the default serialized representation 
     custom_data = {'barrios': {'barrio': serializer_data}} # custom representation 
     return Response(custom_data) 
相關問題