mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-28 05:26:07 +00:00
Initial commit
This commit is contained in:
21
api/pagination.py
Normal file
21
api/pagination.py
Normal file
@ -0,0 +1,21 @@
|
||||
from rest_framework import pagination
|
||||
from rest_framework.response import Response
|
||||
|
||||
|
||||
class CustomPagination(pagination.LimitOffsetPagination):
|
||||
def get_paginated_response(self, data):
|
||||
return Response(
|
||||
{
|
||||
"meta": {
|
||||
"total": self.count,
|
||||
"per_page": self.limit,
|
||||
"current_page": int(self.offset / self.limit) + 1,
|
||||
"last_page": int((self.count - 1) / self.limit) + 1,
|
||||
},
|
||||
"links": {
|
||||
"next_page": self.get_next_link(),
|
||||
"previous_page": self.get_previous_link(),
|
||||
},
|
||||
"data": data,
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user