Answers for "paginate on APIView drf"

1

paginate on APIView drf

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)
Posted by: Guest on May-25-2021

Browse Popular Code Answers by Language