Chapter 9: Generic views
queryset
A QuerySet of objects for which the archive serves.
date_field
The name of the DateField or DateTimeField in the QuerySet‘s model that the date-based archive should use to determine the objects on the page.
Optional arguments
month_format
A format string that regulates what format the month parameter uses. This should be in the syntax accepted by Python’s time.strftime. (See Python’s strftime docs at http://www.python.org/doc/current/lib/module-time.html#l2h-1941) It’s set to "%b" by default, which is a three-letter month abbreviation (i.e. “jan”, “feb”, etc.). To change it to use numbers, use "%m".
allow_future
A boolean specifying whether to include “future” objects on this page, as described in the note above.
This view may also take these common arguments (documented above): ●
allow_empty
●
context_processors
●
extra_context
●
mimetype
●
template_loader
●
template_name
●
template_object_name
Template name If template_name isn’t specified, this view will use the template <app_label>/<model_name>_archive_month.html by default. Template context In addition to extra_context, the template’s context will be:
month
A datetime.date object representing the given month.
next_month
A datetime.date object representing the first day of the next month. If the next month is in the future, this will be None.
previous_month
A datetime.date object representing the first day of the previous month. Unlike next_month, this will never be None.
object_list
A list of objects available for the given month. This variable’s name depends on the template_object_name parameter, which is 'object' by default. If template_object_name is 'foo', this variable’s name will be foo_list.
Week archives The django.views.generic.date_based.archive_week view shows all objects in a given week. Note Django believes that weeks start on Sunday, for the perfectly arbitrary reason that Python does, too.
Example Are you starting to see a pattern here yet?
(r'^(?P<year>\d{4})/(?P<week>\d{2})/$', date_based.archive_week, book_info), Required arguments
year
The four-digit year for which the archive serves (a string).
week
The week of the year for which the archive serves (a string).
file:///D|/books/computer/programming/python/books/DJANGO BOOK/09.html (9 of 17)9/28/2007 2:27:38 PM