Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3170: added first_on_page and last_on_page arguments to pagina…

…ted generic views. Thanks, Grimboy.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4591 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b7fa37f9b24a745c55c20e1767b98a647b25dadb 1 parent 5304093
Jacob Kaplan-Moss authored February 26, 2007
8  django/views/generic/list_detail.py
@@ -33,6 +33,12 @@ def object_list(request, queryset, paginate_by=None, page=None,
33 33
             number of pages, total
34 34
         hits
35 35
             number of objects, total
  36
+        last_on_page
  37
+            the result number of the last of object in the
  38
+            object_list (1-indexed)
  39
+        first_on_page
  40
+            the result number of the first object in the
  41
+            object_list (1-indexed)
36 42
     """
37 43
     if extra_context is None: extra_context = {}
38 44
     queryset = queryset._clone()
@@ -57,6 +63,8 @@ def object_list(request, queryset, paginate_by=None, page=None,
57 63
             'page': page,
58 64
             'next': page + 1,
59 65
             'previous': page - 1,
  66
+            'last_on_page': paginator.last_on_page(page - 1),
  67
+            'first_on_page': paginator.first_on_page(page - 1),
60 68
             'pages': paginator.pages,
61 69
             'hits' : paginator.hits,
62 70
         }, context_processors)
6  docs/generic_views.txt
@@ -752,6 +752,12 @@ If the results are paginated, the context will contain these extra variables:
752 752
 
753 753
     * ``previous``: The previous page number, as an integer. This is 1-based.
754 754
 
  755
+    * `last_on_page`: **New in Django development version** The number of the
  756
+      last result on the current page. This is 1-based.
  757
+
  758
+    * `first_on_page`: **New in Django development version** The number of the
  759
+      first result on the current page. This is 1-based.
  760
+
755 761
     * ``pages``: The total number of pages, as an integer.
756 762
 
757 763
     * ``hits``: The total number of objects across *all* pages, not just this

0 notes on commit b7fa37f

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