mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 18:08:38 -06:00
Closes #6441: Improve UI paginator to optimize page object count
This commit is contained in:
parent
a39522a25e
commit
22927bfc76
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
* [#6393](https://github.com/netbox-community/netbox/issues/6393) - Add `description` filter for IP addresses
|
* [#6393](https://github.com/netbox-community/netbox/issues/6393) - Add `description` filter for IP addresses
|
||||||
* [#6400](https://github.com/netbox-community/netbox/issues/6400) - Add cyan color choice for plugin buttons
|
* [#6400](https://github.com/netbox-community/netbox/issues/6400) - Add cyan color choice for plugin buttons
|
||||||
|
* [#6441](https://github.com/netbox-community/netbox/issues/6441) - Improve UI paginator to optimize page object count
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@ from django.core.paginator import Paginator, Page
|
|||||||
|
|
||||||
class EnhancedPaginator(Paginator):
|
class EnhancedPaginator(Paginator):
|
||||||
|
|
||||||
def __init__(self, object_list, per_page, **kwargs):
|
def __init__(self, object_list, per_page, orphans=None, **kwargs):
|
||||||
|
|
||||||
|
# Determine the page size
|
||||||
try:
|
try:
|
||||||
per_page = int(per_page)
|
per_page = int(per_page)
|
||||||
if per_page < 1:
|
if per_page < 1:
|
||||||
@ -12,7 +14,13 @@ class EnhancedPaginator(Paginator):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
per_page = settings.PAGINATE_COUNT
|
per_page = settings.PAGINATE_COUNT
|
||||||
|
|
||||||
super().__init__(object_list, per_page, **kwargs)
|
# Set orphans count based on page size
|
||||||
|
if orphans is None and per_page <= 50:
|
||||||
|
orphans = 5
|
||||||
|
elif orphans is None:
|
||||||
|
orphans = 10
|
||||||
|
|
||||||
|
super().__init__(object_list, per_page, orphans=orphans, **kwargs)
|
||||||
|
|
||||||
def _get_page(self, *args, **kwargs):
|
def _get_page(self, *args, **kwargs):
|
||||||
return EnhancedPage(*args, **kwargs)
|
return EnhancedPage(*args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user