Opened 9 years ago

Closed 9 years ago

#4053 closed (invalid)

implicitly control in paginator causes unexpected return values.

Reported by: meren@… Owned by: adrian
Component: Core (Other) Version: master
Severity: Keywords: paginator
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



Pagiantor doesn't check the 'page_number' value in "has_next_page" and "has_previous_page" functions. It causes this:

>>> from django.core.paginator import ObjectPaginator
>>> from import Entry
>>> e = Entry.objects.all()
>>> len(e)
>>> paginator_result = ObjectPaginator(e, 10)
>>> paginator_result.pages
>>> page_number = 0
>>> paginator_result.has_next_page(page_number)
>>> paginator_result.has_previous_page(page_number)
>>> page_number = "0"
>>> paginator_result.has_next_page(page_number)
>>> paginator_result.has_previous_page(page_number)

Please review the patch attached below (I'm sorry if ticket is in the wrong component, I couldn't find any closer).


  1. Murat Eren.

Attachments (1)

paginator-check_int.diff (942 bytes) - added by meren@… 9 years ago.

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by meren@…

comment:1 Changed 9 years ago by Brian Rosner <brosner@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

I think in this case that the type conversion should be done before passing it in to has_*_page methods. These methods shouldn't care where the data came from.

Note: See TracTickets for help on using tickets.
Back to Top