Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1033 -- pagination in object_list generic views now use 1-inde…

…xed page numbers in the URL. Thanks, Tom Tobin.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2426 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit da310cff674aa3d91f7e54772faf828a46071812 1 parent 47f040d
Jacob Kaplan-Moss authored February 27, 2006

Showing 1 changed file with 8 additions and 8 deletions. Show diff stats Hide diff stats

  1. 16  django/views/generic/list_detail.py
16  django/views/generic/list_detail.py
@@ -39,22 +39,22 @@ def object_list(request, app_label, module_name, paginate_by=None, allow_empty=F
39 39
     lookup_kwargs = extra_lookup_kwargs.copy()
40 40
     if paginate_by:
41 41
         paginator = ObjectPaginator(mod, lookup_kwargs, paginate_by)
42  
-        page = request.GET.get('page', 0)
  42
+        page = request.GET.get('page', 1)
43 43
         try:
44  
-            object_list = paginator.get_page(page)
45  
-        except InvalidPage:
46  
-            if page == 0 and allow_empty:
  44
+            page = int(page)
  45
+            object_list = paginator.get_page(page - 1)
  46
+        except (InvalidPage, ValueError):
  47
+            if page == 1 and allow_empty:
47 48
                 object_list = []
48 49
             else:
49 50
                 raise Http404
50  
-        page = int(page)
51 51
         c = DjangoContext(request, {
52 52
             'object_list': object_list,
53 53
             'is_paginated': paginator.pages > 1,
54 54
             'results_per_page': paginate_by,
55  
-            'has_next': paginator.has_next_page(page),
56  
-            'has_previous': paginator.has_previous_page(page),
57  
-            'page': page + 1,
  55
+            'has_next': paginator.has_next_page(page - 1),
  56
+            'has_previous': paginator.has_previous_page(page - 1),
  57
+            'page': page,
58 58
             'next': page + 1,
59 59
             'previous': page - 1,
60 60
             'pages': paginator.pages,

0 notes on commit da310cf

Please sign in to comment.
Something went wrong with that request. Please try again.