From dd99c395a0a0afd19e1c215db8be0d6e8a8b726d Mon Sep 17 00:00:00 2001 From: "afanasyev.aa" Date: Mon, 7 Jul 2025 23:15:29 +0900 Subject: [PATCH] fixed pagination --- api/custom_pagination.py | 17 +++++++++++ .../__pycache__/tawhiri.cpython-313.pyc | Bin 3444 -> 3446 bytes api/views.py | 28 ++++++++++++++---- testapi/settings.py | 21 ++++++------- 4 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 api/custom_pagination.py diff --git a/api/custom_pagination.py b/api/custom_pagination.py new file mode 100644 index 0000000..6d37de8 --- /dev/null +++ b/api/custom_pagination.py @@ -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 + }) \ No newline at end of file diff --git a/api/services/__pycache__/tawhiri.cpython-313.pyc b/api/services/__pycache__/tawhiri.cpython-313.pyc index 4e13d6edead3f4c72aa5d9288e274ffd27b52acf..18b9ffccf3e3e520baaf62de24636881a2bfaccc 100644 GIT binary patch delta 45 zcmew&^-YTBGcPX}0}y1(#b#{eX``7F?kK^ delta 43 xcmew+^+k&3GcPX}0}zBWe@x%V)4(L4?rarPlv