标签:五个 object 配置 objects views mode paginati class ble
响应式
如果在setting配置下列,当只有BrowsableAPIRenderer时,只会返回浏览器页面;当配置成JSONRenderer,会返回json数据 REST_FRAMEWORK={ ‘DEFAULT_RENDERER_CLASSES‘: ( ‘rest_framework.renderers.JSONRenderer‘, ‘rest_framework.renderers.BrowsableAPIRenderer‘, ), }
分页器
####分页 from rest_framework.pagination import PageNumberPagination class MyPageNumberPagination(PageNumberPagination): #继承 page_size = 3 #页码 from rest_framework.viewsets import ModelViewSet class CustomerView(ModelViewSet): #将五个数据接口全部封装在了ModelViewSet queryset = Customer.objects.all() serializer_class = CustomerSerializer pagination_class = MyPageNumberPagination #分页
标签:五个 object 配置 objects views mode paginati class ble
原文地址:https://www.cnblogs.com/djfboai/p/10089148.html