Skip to content

Instantly share code, notes, and snippets.

@walison17
Created May 29, 2021 15:21
Show Gist options
  • Save walison17/ec170445e574f085ba0e96a4888c3051 to your computer and use it in GitHub Desktop.
Save walison17/ec170445e574f085ba0e96a4888c3051 to your computer and use it in GitHub Desktop.
from rest_framework.pagination import PageNumberPagination
class CustomPageNumberPagination(PageNumberPagination):
def get_paginated_response(self, data):
return Response({
'count': self.page.paginator.count,
'current_page': self.page.number,
'next': self.get_next_link(),
'previous': self.get_previous_link(),
'results': data
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment