diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index eaa89b954..7ebee9631 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -19,6 +19,7 @@ * [#7647](https://github.com/netbox-community/netbox/issues/7647) - Require interface assignment when designating IP address as primary for device/VM during CSV import * [#7664](https://github.com/netbox-community/netbox/issues/7664) - Preserve initial form data when bulk edit validation fails * [#7717](https://github.com/netbox-community/netbox/issues/7717) - Restore missing tags column on IP range table +* [#7721](https://github.com/netbox-community/netbox/issues/7721) - Retain pagination preference when `MAX_PAGE_SIZE` is zero --- diff --git a/netbox/utilities/paginator.py b/netbox/utilities/paginator.py index e46af4b3e..85ceab73d 100644 --- a/netbox/utilities/paginator.py +++ b/netbox/utilities/paginator.py @@ -57,17 +57,22 @@ def get_paginate_count(request): Return the lesser of the calculated value and MAX_PAGE_SIZE. """ + def _max_allowed(page_size): + if settings.MAX_PAGE_SIZE: + return min(page_size, settings.MAX_PAGE_SIZE) + return page_size + if 'per_page' in request.GET: try: per_page = int(request.GET.get('per_page')) if request.user.is_authenticated: request.user.config.set('pagination.per_page', per_page, commit=True) - return min(per_page, settings.MAX_PAGE_SIZE) + return _max_allowed(per_page) except ValueError: pass if request.user.is_authenticated: per_page = request.user.config.get('pagination.per_page', settings.PAGINATE_COUNT) - return min(per_page, settings.MAX_PAGE_SIZE) + return _max_allowed(per_page) - return min(settings.PAGINATE_COUNT, settings.MAX_PAGE_SIZE) + return _max_allowed(settings.PAGINATE_COUNT)