cineclub-site/server/myapi/pagination/PagePaginationWithPageCount.py

14 lines
423 B
Python
Raw Normal View History

from rest_framework import pagination
from rest_framework.response import Response
class PagePaginationWithPageCount(pagination.PageNumberPagination):
def get_paginated_response(self, data):
return Response({
'current_page': self.page.number,
'total_results': self.page.paginator.count,
'total_pages': self.page.paginator.num_pages,
'results': data
})