| 1 |
Index: django/views/generic/date_based.py |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- django/views/generic/date_based.py (Revision 6147) |
|---|
| 4 |
+++ django/views/generic/date_based.py (Arbeitskopie) |
|---|
| 5 |
@@ -10,7 +10,7 @@ |
|---|
| 6 |
def archive_index(request, queryset, date_field, num_latest=15, |
|---|
| 7 |
template_name=None, template_loader=loader, |
|---|
| 8 |
extra_context=None, allow_empty=False, context_processors=None, |
|---|
| 9 |
- mimetype=None, allow_future=False): |
|---|
| 10 |
+ mimetype=None, allow_future=False, template_object_name='latest'): |
|---|
| 11 |
""" |
|---|
| 12 |
Generic top-level archive of date-based objects. |
|---|
| 13 |
|
|---|
| 14 |
@@ -39,7 +39,7 @@ |
|---|
| 15 |
t = template_loader.get_template(template_name) |
|---|
| 16 |
c = RequestContext(request, { |
|---|
| 17 |
'date_list' : date_list, |
|---|
| 18 |
- 'latest' : latest, |
|---|
| 19 |
+ template_object_name : latest, |
|---|
| 20 |
}, context_processors) |
|---|
| 21 |
for key, value in extra_context.items(): |
|---|
| 22 |
if callable(value): |
|---|
| 23 |
Index: docs/generic_views.txt |
|---|
| 24 |
=================================================================== |
|---|
| 25 |
--- docs/generic_views.txt (Revision 6147) |
|---|
| 26 |
+++ docs/generic_views.txt (Arbeitskopie) |
|---|
| 27 |
@@ -201,6 +201,9 @@ |
|---|
| 28 |
specified in ``date_field`` is greater than the current date/time. By |
|---|
| 29 |
default, this is ``False``. |
|---|
| 30 |
|
|---|
| 31 |
+ * ``template_object_name``: Designates the name of the template variable |
|---|
| 32 |
+ to use in the template context. By default, this is ``'latest'``. |
|---|
| 33 |
+ |
|---|
| 34 |
**Template name:** |
|---|
| 35 |
|
|---|
| 36 |
If ``template_name`` isn't specified, this view will use the template |
|---|
| 37 |
@@ -221,9 +224,12 @@ |
|---|
| 38 |
years that have objects available according to ``queryset``. These are |
|---|
| 39 |
ordered in reverse. This is equivalent to |
|---|
| 40 |
``queryset.dates(date_field, 'year')[::-1]``. |
|---|
| 41 |
+ |
|---|
| 42 |
* ``latest``: The ``num_latest`` objects in the system, ordered descending |
|---|
| 43 |
by ``date_field``. For example, if ``num_latest`` is ``10``, then |
|---|
| 44 |
- ``latest`` will be a list of the latest 10 objects in ``queryset``. |
|---|
| 45 |
+ ``latest`` will be a list of the latest 10 objects in ``queryset``. This |
|---|
| 46 |
+ variable's name depends on the ``template_object_name`` parameter, which |
|---|
| 47 |
+ is ``'latest'`` by default. |
|---|
| 48 |
|
|---|
| 49 |
.. _RequestContext docs: ../templates_python/#subclassing-context-requestcontext |
|---|
| 50 |
|
|---|