Permalink
Browse files

Fixed #5932 -- Use `self.pages` and not `self._pages` in `_get_page_r…

…ange` so that an exception is not raised if `self.page_range` is accessed before `self.pages`.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6702 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 1607ace commit 6522e0697a84a7628decbc86e2954b5cd430d0c0 @gdub gdub committed Nov 19, 2007
Showing with 3 additions and 2 deletions.
  1. +1 −1 django/core/paginator.py
  2. +2 −1 tests/modeltests/pagination/models.py
@@ -91,7 +91,7 @@ def _get_page_range(self):
a template for loop.
"""
if self._page_range is None:
- self._page_range = range(1, self._pages + 1)
+ self._page_range = range(1, self.pages + 1)
return self._page_range
hits = property(_get_hits)
@@ -78,7 +78,8 @@ def __unicode__(self):
>>> paginator.pages
2
-# The paginator can provide a list of all available pages
+# The paginator can provide a list of all available pages.
+>>> paginator = ObjectPaginator(Article.objects.all(), 10)
>>> paginator.page_range
[1, 2]
"""}

0 comments on commit 6522e06

Please sign in to comment.