标签:views use 次数 rate nat obj queryset sse 分享
1.在Lib\site-packages\rest_framework\settings.py中查看:
2.简单分页在项目setting中配置:(所有get请求返回数据每页5条)
#每页五条数据 REST_FRAMEWORK={ ‘DEFAULT_PAGINATION_CLASS‘:‘rest_framework.pagination.PageNumberPagination‘, ‘PAGE_SIZE‘:5 }
from rest_framework.pagination import PageNumberPagination #深度定制分页 class GoodsPagination(PageNumberPagination): page_size = 12 page_size_query_param = ‘page_size‘ #名称 page_query_param = ‘page‘ #单页数量最多 max_page_size = 100 class GoodsListViewSet(CacheResponseMixin,mixins.ListModelMixin,mixins.RetrieveModelMixin,viewsets.GenericViewSet): """ 商品详情页,分页,搜索,过滤,排序 """ #配置ip限制访问次数 throttle_classes = (UserRateThrottle,AnonRateThrottle) queryset = Goods.objects.all() serializer_class = GoodsSerializer #分页,调用分页定制类 pagination_class = GoodsPagination
标签:views use 次数 rate nat obj queryset sse 分享
原文地址:https://www.cnblogs.com/lyq-biu/p/9652261.html