Web pagination broken when MAX_PAGE_SIZE = 0 #5596

Closed
opened 2025-12-29 19:29:57 +01:00 by adam · 2 comments
Owner

Originally created by @jhammond-git on GitHub (Nov 3, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.8

Python version

3.8

Steps to Reproduce

  1. Set MAX_PAGE_SIZE to 0 in configuration.py. If necessary, restart Netbox services.
  2. Log into Netbox.
  3. Go to any table that supports pagination.
  4. Change your page size from the default.
  5. Browse to a different table that supports pagination.

Expected Behavior

Your pages should be the same size that you changed them to in step 4.

Observed Behavior

Page size is switched back to default. When checking user preferences, the pagination.per_page setting is updated correctly, but not honored.

Originally created by @jhammond-git on GitHub (Nov 3, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.8 ### Python version 3.8 ### Steps to Reproduce 1. Set MAX_PAGE_SIZE to 0 in configuration.py. If necessary, restart Netbox services. 2. Log into Netbox. 3. Go to any table that supports pagination. 4. Change your page size from the default. 5. Browse to a different table that supports pagination. ### Expected Behavior Your pages should be the same size that you changed them to in step 4. ### Observed Behavior Page size is switched back to default. When checking user preferences, the pagination.per_page setting is updated correctly, but not honored.
adam added the type: bugstatus: accepted labels 2025-12-29 19:29:57 +01:00
adam closed this issue 2025-12-29 19:29:57 +01:00
Author
Owner

@jhammond-git commented on GitHub (Nov 3, 2021):

I'm not sure if I'm following the logic correctly, but this is how I read it.

The function get_paginate_count is called. That function, among other things, returns the smallest of per_page or PAGINATE_COUNT and MAX_PAGE_SIZE.

The example I was looking at then created an EnhancedPaginator object which would set the per_page attribute to that returned value, or if 0, set per_page to PAGINATE_COUNT (which in my environment is the default of 50).

I must be missing something because all our pages were set at 25 when MAX_PAGE_SIZE was 0.

@jhammond-git commented on GitHub (Nov 3, 2021): I'm not sure if I'm following the logic correctly, but this is how I read it. The function get_paginate_count is called. That function, among other things, returns the smallest of per_page or PAGINATE_COUNT and MAX_PAGE_SIZE. The example I was looking at then created an EnhancedPaginator object which would set the per_page attribute to that returned value, or if 0, set per_page to PAGINATE_COUNT (which in my environment is the default of 50). I must be missing something because all our pages were set at 25 when MAX_PAGE_SIZE was 0.
Author
Owner

@jeremystretch commented on GitHub (Nov 3, 2021):

The problem was in the get_paginate_count() function, which was returning min(per_page, settings.MAX_PAGE_SIZE) without regard to whether MAX_PAGE_SIZE was non-zero. Thanks for the report!

@jeremystretch commented on GitHub (Nov 3, 2021): The problem was in the `get_paginate_count()` function, which was returning `min(per_page, settings.MAX_PAGE_SIZE)` without regard to whether `MAX_PAGE_SIZE` was non-zero. Thanks for the report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5596