diff --git a/django/core/paginator.py b/django/core/paginator.py index 3cec491905..bd8757c708 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -13,8 +13,8 @@ class EmptyPage(InvalidPage): class Paginator(object): def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True): self.object_list = object_list - self.per_page = per_page - self.orphans = orphans + self.per_page = int(per_page) + self.orphans = int(orphans) self.allow_empty_first_page = allow_empty_first_page self._num_pages = self._count = None diff --git a/tests/regressiontests/pagination_regress/tests.py b/tests/regressiontests/pagination_regress/tests.py index 3feeae9083..9f381a5981 100644 --- a/tests/regressiontests/pagination_regress/tests.py +++ b/tests/regressiontests/pagination_regress/tests.py @@ -94,6 +94,11 @@ class PaginatorTests(TestCase): (([1, 2], 1, 1, True), (2, 1, [1])), (([1, 2, 3], 2, 1, True), (3, 1, [1])), ((eleven, 10, 1, True), (11, 1, [1])), + # Non-integer inputs + ((ten, '4', 1, False), (10, 3, [1, 2, 3])), + ((ten, u'4', 1, False), (10, 3, [1, 2, 3])), + ((ten, 4, '1', False), (10, 3, [1, 2, 3])), + ((ten, 4, u'1', False), (10, 3, [1, 2, 3])), ) for params, output in tests: self.check_paginator(params, output)