django-restful-api 默认分页和自定义分页

自定义分页

	class MessageLevelTwoPagination(PageNumberPagination):
	    """
	    消息中心二级页面自定义分页
	    """
	    # 默认每页显示的个数
	    page_size = 8
	    # 可以动态改变每页显示的个数
	    page_size_query_param = 'page_size'
	    # 页码参数
	    page_query_param = 'page'

默认分页

	from utils.pagination import DefaultPagination
	
	class JumpserverApplicationViewSet(mixins.CreateModelMixin,
	                                   mixins.ListModelMixin,
	                                   mixins.RetrieveModelMixin,
	                                   mixins.UpdateModelMixin,
	                                   viewsets.GenericViewSet):
	    permission_classes = (IsAuthenticated,) 
	    filter_backends = (DjangoFilterBackend, filters.SearchFilter,)
	    filter_class = ApplicationFilter
	    pagination_class = DefaultPagination    #!!!!!!!!!!!!!!!!

你可能感兴趣的:(django-restful-api 默认分页和自定义分页)