关于drf分页url参数params
page和size
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class MinePageNumberPagination(PageNumberPagination):
page_size_query_param = 'size' # 允许通过查询参数指定每页条数
max_page_size = 150
def get_paginated_response(self, data):
return Response({
'count': self.page.paginator.count,
'page_size': self.request.query_params.get('size', self.page_size),
'results': data,
})