From b0b6e5734d28e08764892dac236da8081e39c2a9 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 28 Oct 2025 14:55:58 +0330 Subject: [PATCH] paginate organization type --- apps/authentication/api/v1/api.py | 7 +++++-- logs/django_requests.log | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/authentication/api/v1/api.py b/apps/authentication/api/v1/api.py index 9a42096..961839c 100644 --- a/apps/authentication/api/v1/api.py +++ b/apps/authentication/api/v1/api.py @@ -213,8 +213,11 @@ class OrganizationTypeViewSet(SoftDeleteMixin, ModelViewSet): def list(self, request, *args, **kwargs): """ all organization type """ queryset = self.get_queryset().order_by('-modify_date') - serializer = self.serializer_class(queryset, many=True) - return Response(serializer.data, status=status.HTTP_200_OK) + page = self.paginate_queryset(queryset.order_by('-create_date')) # paginate queryset + + if page is not None: # noqa + serializer = self.serializer_class(page, many=True) + return self.get_paginated_response(serializer.data) class OrganizationViewSet(BaseViewSet, SoftDeleteMixin, ModelViewSet, DynamicSearchMixin): diff --git a/logs/django_requests.log b/logs/django_requests.log index c681011..8592db6 100644 --- a/logs/django_requests.log +++ b/logs/django_requests.log @@ -322,3 +322,4 @@ django.core.exceptions.FieldError: Unsupported lookup 'name' for ForeignKey or j [2025-10-28 14:28:55,553] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-10-28 14:35:00,268] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading. [2025-10-28 14:35:02,391] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-10-28 14:55:17,922] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.