Django

Code

Changeset 6157

Show
Ignore:
Timestamp:
09/13/07 22:54:28 (1 year ago)
Author:
russellm
Message:

Fixed #3895 -- Added ability to customize the context variable in the archive_index generic view. Thanks to marco.giusti@gmail.com and toke-django@toke.de.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/views/generic/date_based.py

    r6058 r6157  
    1111        template_name=None, template_loader=loader, 
    1212        extra_context=None, allow_empty=False, context_processors=None, 
    13         mimetype=None, allow_future=False): 
     13        mimetype=None, allow_future=False, template_object_name='latest'): 
    1414    """ 
    1515    Generic top-level archive of date-based objects. 
     
    4040    c = RequestContext(request, { 
    4141        'date_list' : date_list, 
    42         'latest' : latest, 
     42        template_object_name : latest, 
    4343    }, context_processors) 
    4444    for key, value in extra_context.items(): 
  • django/trunk/docs/generic_views.txt

    r6149 r6157  
    202202      default, this is ``False``. 
    203203 
     204    * ``template_object_name``: Designates the name of the template variable 
     205      to use in the template context. By default, this is ``'latest'``. 
     206 
    204207**Template name:** 
    205208 
     
    222225      ordered in reverse. This is equivalent to 
    223226      ``queryset.dates(date_field, 'year')[::-1]``. 
     227 
    224228    * ``latest``: The ``num_latest`` objects in the system, ordered descending 
    225229      by ``date_field``. For example, if ``num_latest`` is ``10``, then 
    226       ``latest`` will be a list of the latest 10 objects in ``queryset``. 
     230      ``latest`` will be a list of the latest 10 objects in ``queryset``. This 
     231      variable's name depends on the ``template_object_name`` parameter, which 
     232      is ``'latest'`` by default. If ``template_object_name`` is ``'foo'``,  
     233      this variable's name will be ``foo``. 
    227234 
    228235.. _RequestContext docs: ../templates_python/#subclassing-context-requestcontext