📜  在 APIView drf 上分页 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:54.242000             🧑  作者: Mango

代码示例1
class NameOfView(APIView):

    def get(self, request):
        paginator = CustomPagination()
        queryset = Model.objects.all()
        paginate_queryset = paginator.paginate_queryset(queryset, request)
        serialize_pagination = SerializerClass(paginate_queryset, many=True).data
        data = paginator.get_paginated_response(serialize_pagination).data
        return Response(data)