标签:query djang roles models row setting *args frame object
渲染器: from rest_framework.renderers import BrowsableAPIRenderer,AdminRenderer,HTMLFormRenderer,JSONRenderer class TestView(APIView): renderer_classes = [JSONRenderer,BrowsableAPIRenderer, ] #建议只加这两个 get(self,reuqest,*args,**kwargs): #获取数据 models.Role.objects.all() roles = self.get_queryset() pager_roles = self.paginate_queryset(roles) #序列化 self.get_serializer(instance=pager_roles,many=True) return Response(ser.data) 全局配置: "DEFAULT_RENDERER_CLASSES": [‘‘, ‘rest_framework.renderers.JSONRenderer‘, ‘rest_framework.renderers.BrowsableAPIRenderer‘, ], 推荐写到settings里面
Django rest-framework框架-组件之渲染器
标签:query djang roles models row setting *args frame object
原文地址:https://www.cnblogs.com/kuku0223/p/11352723.html