This commit is contained in:
chenyang
2022-07-02 08:52:08 +08:00
parent 0a244b34cc
commit 43e1402c74
6 changed files with 132 additions and 52 deletions
+19
View File
@@ -0,0 +1,19 @@
from rest_framework.pagination import PageNumberPagination
from server.util.constant_util import *
from rest_framework.response import Response
class DefaultNumberPagination(PageNumberPagination):
page_size = 1 # default page size
page_size_query_param = 'page_size' # ?page=xx&page_size=??
max_page_size = 50 # max page size
def get_paginated_response(self, data):
"""
重写返回值格式
"""
return Response({
'code': CODE_SUCCESS,
'count': self.page.paginator.count,
'results': data
})