[1.7.x] Fixed #23088 -- Used `six` `range` type in `Paginator.page_range`.

Backport of 6508db2ff9 from master
This commit is contained in:
Moayad Mardini 2014-07-25 11:04:58 +03:00 committed by Tim Graham
parent 0ac986fd8c
commit ce95ab8f02
2 changed files with 8 additions and 1 deletions

View File

@ -96,7 +96,7 @@ class Paginator(object):
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)

View File

@ -232,6 +232,13 @@ class PaginationTests(unittest.TestCase):
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):
"""