mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-02-22 23:12:00 +00:00
22 lines
718 B
Python
22 lines
718 B
Python
|
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,
|
||
|
}
|
||
|
)
|