update
This commit is contained in:
@@ -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
|
||||
})
|
||||
@@ -1,6 +0,0 @@
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
|
||||
|
||||
class NewPagination(PageNumberPagination):
|
||||
page_size = 2
|
||||
page_size_query_param = 'page_size'
|
||||
@@ -8,7 +8,7 @@ from rest_framework.views import APIView
|
||||
from server.filters import CooperationMindFilter
|
||||
from server.serializers import *
|
||||
from server.util.mix_util import build_response
|
||||
from server.util.pagination import NewPagination
|
||||
from server.pagination import DefaultNumberPagination
|
||||
from server_auth.lib.auth import LoginRequiredJSONMixin
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
serializer_class = CooperationMindSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filter_class = CooperationMindFilter
|
||||
pagination_class = NewPagination
|
||||
pagination_class = DefaultNumberPagination
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user