Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1302 -- Added next_month and previous_month to template contex…

…t 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
  • Loading branch information...
commit 6b694097dc22569f1b86feec20a1ff30a2b14b26 1 parent b3f99ec
Adrian Holovaty authored
8  django/views/generic/date_based.py
@@ -95,7 +95,11 @@ def archive_month(request, year, month, app_label, module_name, date_field,
95 95
     Templates: ``<app_label>/<module_name>_archive_month``
96 96
     Context:
97 97
         month:
98  
-            this month
  98
+            (date) this month
  99
+        next_month:
  100
+            (date) the first day of the next month, or None if the next month is in the future
  101
+        previous_month:
  102
+            (date) the first day of the previous month
99 103
         object_list:
100 104
             list of objects published in the given month
101 105
     """
@@ -126,6 +130,8 @@ def archive_month(request, year, month, app_label, module_name, date_field,
126 130
     c = DjangoContext(request, {
127 131
         'object_list': object_list,
128 132
         'month': date,
  133
+        'next_month': (last_day < datetime.date.today()) and (last_day + datetime.timedelta(days=1)) or None,
  134
+        'previous_month': first_day - datetime.timedelta(days=1),
129 135
     }, context_processors)
130 136
     for key, value in extra_context.items():
131 137
         if callable(value):
9  docs/generic_views.txt
@@ -192,7 +192,14 @@ The date-based generic functions are:
192 192
     Has the following template context:
193 193
 
194 194
         ``month``
195  
-            The given month (a datetime.datetime object)
  195
+            The given month (a datetime.date object)
  196
+        ``next_month``
  197
+            **New in Django development version.** The first day of the next
  198
+            month, or None if the next month is in the future (a datetime.date
  199
+            object)
  200
+        ``previous_month``
  201
+            **New in Django development version.** The first day of the
  202
+            previous month (a datetime.date object)
196 203
         ``object_list``
197 204
             List of objects published in the given month
198 205
 

0 notes on commit 6b69409

Please sign in to comment.
Something went wrong with that request. Please try again.