我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用rest_framework.generics.ListAPIView()。
def retrieve(self, request, *args, **kwargs): chairman = Chairman(id=kwargs['id']) serializer = self.get_serializer(chairman) return Response(serializer.data) # class ChairmanList(generics.ListAPIView): # queryset = Chairman.objects.all().order('-num') # serializer_class = ChairmanSerializer # # # class ChairmanDetail(mixins.RetrieveModelMixin, # generics.GenericAPIView): # queryset = Chairman.objects.all() # serializer_class = ChairmanSerializer # lookup_field = ('id') # # def get(self, request, *args, **kwargs): # chairman = Chairman(id=kwargs['id']) # serializer = self.get_serializer(chairman) # return Response(serializer.data)