Django

Code

Ticket #3170: first_and_last_on_page_object_list.diff

File first_and_last_on_page_object_list.diff, 1.7 kB (added by Grimboy, 2 years ago)
  • django/views/generic/list_detail.py

    old new  
    3333            number of pages, total 
    3434        hits 
    3535            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) 
    3642    """ 
    3743    if extra_context is None: extra_context = {} 
    3844    queryset = queryset._clone() 
     
    5763            'page': page, 
    5864            'next': page + 1, 
    5965            'previous': page - 1, 
     66            'last_on_page': paginator.last_on_page(page - 1), 
     67            'first_on_page': paginator.first_on_page(page - 1), 
    6068            'pages': paginator.pages, 
    6169            'hits' : paginator.hits, 
    6270        }, context_processors) 
  • docs/generic_views.txt

    old new  
    752752 
    753753    * ``previous``: The previous page number, as an integer. This is 1-based. 
    754754 
     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 
    755761    * ``pages``: The total number of pages, as an integer. 
    756762 
    757763    * ``hits``: The total number of objects across *all* pages, not just this