Author: russellm
Date: 2007-09-13 22:54:28 -0500 (Thu, 13 Sep 2007)
New Revision: 6157

Modified:
   django/trunk/django/views/generic/date_based.py
   django/trunk/docs/generic_views.txt
Log:
Fixed #3895 -- Added ability to customize the context variable in the 
archive_index generic view. Thanks to [EMAIL PROTECTED] and [EMAIL PROTECTED]


Modified: django/trunk/django/views/generic/date_based.py
===================================================================
--- django/trunk/django/views/generic/date_based.py     2007-09-14 03:29:39 UTC 
(rev 6156)
+++ django/trunk/django/views/generic/date_based.py     2007-09-14 03:54:28 UTC 
(rev 6157)
@@ -10,7 +10,7 @@
 def archive_index(request, queryset, date_field, num_latest=15,
         template_name=None, template_loader=loader,
         extra_context=None, allow_empty=False, context_processors=None,
-        mimetype=None, allow_future=False):
+        mimetype=None, allow_future=False, template_object_name='latest'):
     """
     Generic top-level archive of date-based objects.
 
@@ -39,7 +39,7 @@
     t = template_loader.get_template(template_name)
     c = RequestContext(request, {
         'date_list' : date_list,
-        'latest' : latest,
+        template_object_name : latest,
     }, context_processors)
     for key, value in extra_context.items():
         if callable(value):

Modified: django/trunk/docs/generic_views.txt
===================================================================
--- django/trunk/docs/generic_views.txt 2007-09-14 03:29:39 UTC (rev 6156)
+++ django/trunk/docs/generic_views.txt 2007-09-14 03:54:28 UTC (rev 6157)
@@ -201,6 +201,9 @@
       specified in ``date_field`` is greater than the current date/time. By
       default, this is ``False``.
 
+    * ``template_object_name``: Designates the name of the template variable
+      to use in the template context. By default, this is ``'latest'``.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -221,9 +224,13 @@
       years that have objects available according to ``queryset``. These are
       ordered in reverse. This is equivalent to
       ``queryset.dates(date_field, 'year')[::-1]``.
+
     * ``latest``: The ``num_latest`` objects in the system, ordered descending
       by ``date_field``. For example, if ``num_latest`` is ``10``, then
-      ``latest`` will be a list of the latest 10 objects in ``queryset``.
+      ``latest`` will be a list of the latest 10 objects in ``queryset``. This
+      variable's name depends on the ``template_object_name`` parameter, which
+      is ``'latest'`` by default. If ``template_object_name`` is ``'foo'``, 
+      this variable's name will be ``foo``.
 
 .. _RequestContext docs: 
../templates_python/#subclassing-context-requestcontext
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to