DRF pagination issue in APIView
Question:
I want to implement LimitOffsetPagination
in my APIView
which was successful but the url
is required to be appended with ?limit=<int>
.
Something like this:
But I do not want to manually add that endpoint.
So I tried creating a new pagination.py
file:
But now I am not getting the pagination prompt for navigation to next post like before.
I think return
needs to be altered?
Answers:
You just need to change your return. Instead of return Response(serializer.data)
use return paginator.get_paginated_response(serializer.data)
I want to implement LimitOffsetPagination
in my APIView
which was successful but the url
is required to be appended with ?limit=<int>
.
Something like this:
But I do not want to manually add that endpoint.
So I tried creating a new pagination.py
file:
But now I am not getting the pagination prompt for navigation to next post like before.
I think return
needs to be altered?
You just need to change your return. Instead of return Response(serializer.data)
use return paginator.get_paginated_response(serializer.data)