Skip to content

Commit

Permalink
Fixed #23088 -- Used six range type in Paginator.page_range.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmardini committed Jul 25, 2014
1 parent bb395a1 commit 6508db2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/core/paginator.py
Expand Up @@ -96,7 +96,7 @@ def _get_page_range(self):
Returns a 1-based range of pages for iterating through within
a template for loop.
"""
return range(1, self.num_pages + 1)
return six.moves.range(1, self.num_pages + 1)
page_range = property(_get_page_range)


Expand Down
7 changes: 7 additions & 0 deletions tests/pagination/tests.py
Expand Up @@ -232,6 +232,13 @@ def test_get_page_hook(self):
self.assertEqual(page2.previous_page_number(), 1)
self.assertIsNone(page2.next_page_number())

def test_page_range_type(self):
"""
Ticket #23088: Paginator.page_range is of inconsistent type in Py2/Py3
"""
paginator = Paginator([1, 2, 3], 2)
self.assertEqual(type(paginator.page_range), six.moves.range)


class ModelPaginationTests(TestCase):
"""
Expand Down

0 comments on commit 6508db2

Please sign in to comment.