fixed pagination
This commit is contained in:
parent
80ffab27e9
commit
dd99c395a0
4 changed files with 51 additions and 15 deletions
17
api/custom_pagination.py
Normal file
17
api/custom_pagination.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from rest_framework.pagination import LimitOffsetPagination
|
||||
from rest_framework.response import Response
|
||||
|
||||
class CustomLimitOffsetPagination(LimitOffsetPagination):
|
||||
limit_query_param = 'limit'
|
||||
offset_query_param = 'skip'
|
||||
max_limit = 100
|
||||
default_limit = 10
|
||||
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
return Response({
|
||||
'total': self.count,
|
||||
'limit': self.limit,
|
||||
'skip': self.offset,
|
||||
'predictions': data
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue