Answers for "drf pagination apiview"

1

drf default pagination

REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 100
}
Posted by: Guest on August-15-2021
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