Advertisement
OlegKl

Untitled

Aug 6th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from rest_framework.response import Response
  2. from rest_framework.pagination import PageNumberPagination
  3.  
  4. __all__ = (
  5. 'MetaResponsePagination',
  6. )
  7.  
  8.  
  9. class MetaResponsePagination(PageNumberPagination):
  10. page_size = 12
  11. page_size_query_param = 'page_size'
  12. max_page_size = 1000
  13.  
  14. def get_paginated_response(self, data):
  15. return Response({
  16. 'meta': { # pagination meta data
  17. 'count': self.page.paginator.count,
  18. 'page': self.page.number,
  19. 'perPage': self.get_page_size(self.request)
  20. },
  21. 'data': data
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement