Fixed #1302 -- Added next_month and previous_month to template context in archive_month date-based generic view. Thanks, ubernostrum
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2323 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b3f99ec9fe
commit
6b694097dc
|
@ -95,7 +95,11 @@ def archive_month(request, year, month, app_label, module_name, date_field,
|
||||||
Templates: ``<app_label>/<module_name>_archive_month``
|
Templates: ``<app_label>/<module_name>_archive_month``
|
||||||
Context:
|
Context:
|
||||||
month:
|
month:
|
||||||
this month
|
(date) this month
|
||||||
|
next_month:
|
||||||
|
(date) the first day of the next month, or None if the next month is in the future
|
||||||
|
previous_month:
|
||||||
|
(date) the first day of the previous month
|
||||||
object_list:
|
object_list:
|
||||||
list of objects published in the given month
|
list of objects published in the given month
|
||||||
"""
|
"""
|
||||||
|
@ -126,6 +130,8 @@ def archive_month(request, year, month, app_label, module_name, date_field,
|
||||||
c = DjangoContext(request, {
|
c = DjangoContext(request, {
|
||||||
'object_list': object_list,
|
'object_list': object_list,
|
||||||
'month': date,
|
'month': date,
|
||||||
|
'next_month': (last_day < datetime.date.today()) and (last_day + datetime.timedelta(days=1)) or None,
|
||||||
|
'previous_month': first_day - datetime.timedelta(days=1),
|
||||||
}, context_processors)
|
}, context_processors)
|
||||||
for key, value in extra_context.items():
|
for key, value in extra_context.items():
|
||||||
if callable(value):
|
if callable(value):
|
||||||
|
|
|
@ -192,7 +192,14 @@ The date-based generic functions are:
|
||||||
Has the following template context:
|
Has the following template context:
|
||||||
|
|
||||||
``month``
|
``month``
|
||||||
The given month (a datetime.datetime object)
|
The given month (a datetime.date object)
|
||||||
|
``next_month``
|
||||||
|
**New in Django development version.** The first day of the next
|
||||||
|
month, or None if the next month is in the future (a datetime.date
|
||||||
|
object)
|
||||||
|
``previous_month``
|
||||||
|
**New in Django development version.** The first day of the
|
||||||
|
previous month (a datetime.date object)
|
||||||
``object_list``
|
``object_list``
|
||||||
List of objects published in the given month
|
List of objects published in the given month
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue