diff options
| author | Moayad Mardini <moayad.m@gmail.com> | 2014-07-25 11:04:58 +0300 |
|---|---|---|
| committer | Moayad Mardini <moayad.m@gmail.com> | 2014-07-25 11:04:58 +0300 |
| commit | 6508db2ff9fc5be95fec903b3fa7ab8204fe316a (patch) | |
| tree | cc087a9e840e101ef03a5f80cf5aea0638ec2a00 | |
| parent | bb395a15ba16cc3ae223265afb69ec95f0f78855 (diff) | |
Fixed #23088 -- Used `six` `range` type in `Paginator.page_range`.
| -rw-r--r-- | django/core/paginator.py | 2 | ||||
| -rw-r--r-- | tests/pagination/tests.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/django/core/paginator.py b/django/core/paginator.py index c8b9377856..75292236fa 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -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) diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py index c2ad54c5ad..3ff1306045 100644 --- a/tests/pagination/tests.py +++ b/tests/pagination/tests.py @@ -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): """ |
