From 638b55e84cd49f6298f26e0742e4f81a5705735a Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Fri, 29 May 2026 20:48:28 -0300 Subject: [PATCH] [chores] Standardized REST API pagination Replaced endpoint-specific DRF paginator classes with the shared OpenWispPagination implementation where equivalent settings were already in use. This change reduces duplication and keeps pagination behavior consistent across modules. --- openwisp_ipam/api/views.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/openwisp_ipam/api/views.py b/openwisp_ipam/api/views.py index 51d89e9..c739140 100644 --- a/openwisp_ipam/api/views.py +++ b/openwisp_ipam/api/views.py @@ -10,6 +10,7 @@ FilterByParentManaged, ProtectedAPIMixin as BaseProtectedAPIMixin, ) +from openwisp_utils.api.pagination import OpenWispPagination from rest_framework import pagination, serializers, status from rest_framework.generics import ( CreateAPIView, @@ -48,12 +49,6 @@ class ProtectedAPIMixin(BaseProtectedAPIMixin): throttle_scope = "ipam" -class ListViewPagination(pagination.PageNumberPagination): - page_size = 10 - page_size_query_param = "page_size" - max_page_size = 100 - - class HostsListPagination(pagination.BasePagination): limit = 256 start_query_param = "start" @@ -178,7 +173,7 @@ class IpAddressListCreateView(IpAddressOrgMixin, ProtectedAPIMixin, ListCreateAP queryset = IpAddress.objects.none() subnet_model = Subnet serializer_class = IpAddressSerializer - pagination_class = ListViewPagination + pagination_class = OpenWispPagination def get_queryset(self): subnet = get_object_or_404(self.subnet_model, pk=self.kwargs["subnet_id"]) @@ -190,7 +185,7 @@ class SubnetListCreateView( FilterByOrganizationManaged, ProtectedAPIMixin, ListCreateAPIView ): serializer_class = SubnetSerializer - pagination_class = ListViewPagination + pagination_class = OpenWispPagination queryset = Subnet.objects.all().order_by("subnet")