Ticket #3391: generic_object_list.patch

File generic_object_list.patch, 1.6 KB (added by Max Derkachev <mderk@…>, 17 years ago)

The patch

  • django/views/generic/list_detail.py

     
    4848                object_list = []
    4949            else:
    5050                raise Http404
     51        start = 1   
     52        if page > 1:
     53            start = (page - 1) * paginate_by + 1
     54       
     55        end = start + paginate_by - 1
     56        if end > paginator.hits:
     57            end = paginator.hits   
     58                   
    5159        c = RequestContext(request, {
    5260            '%s_list' % template_object_name: object_list,
    5361            'is_paginated': paginator.pages > 1,
     
    5866            'next': page + 1,
    5967            'previous': page - 1,
    6068            'pages': paginator.pages,
     69            'pages_list': range(1, paginator.pages+1),
     70            'page_start': start,
     71            'page_end': end,
    6172            'hits' : paginator.hits,
    6273        }, context_processors)
    6374    else:
  • docs/generic_views.txt

     
    754754
    755755    * ``pages``: The total number of pages, as an integer.
    756756
     757    * ``pages_list``: The list of page numbers (integers).
     758
     759    * ``page_start``: The number of the first item on the page.
     760
     761    * ``page_end``: The number of the last item on the page.
     762
    757763    * ``hits``: The total number of objects across *all* pages, not just this
    758764      page.
    759765
Back to Top