Changeset 3039
- Timestamp:
- 05/31/06 23:21:26 (2 years ago)
- Files:
-
- django/trunk/django/views/generic/date_based.py (modified) (4 diffs)
- django/trunk/docs/generic_views.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/views/generic/date_based.py
r3022 r3039 46 46 def archive_year(request, year, queryset, date_field, template_name=None, 47 47 template_loader=loader, extra_context={}, allow_empty=False, 48 context_processors=None, mimetype=None): 48 context_processors=None, template_object_name='object', mimetype=None, 49 make_object_list=False): 49 50 """ 50 51 Generic yearly archive view. … … 56 57 year 57 58 This year 59 object_list 60 List of objects published in the given month 61 (Only available if make_object_list argument is True) 58 62 """ 59 63 model = queryset.model … … 68 72 if not date_list and not allow_empty: 69 73 raise Http404 74 if make_object_list: 75 object_list = queryset.filter(**lookup_kwargs).order_by(date_field) 76 else: 77 object_list = [] 70 78 if not template_name: 71 79 template_name = "%s/%s_archive_year.html" % (model._meta.app_label, model._meta.object_name.lower()) … … 74 82 'date_list': date_list, 75 83 'year': year, 84 '%s_list' % template_object_name: object_list, 76 85 }, context_processors) 77 86 for key, value in extra_context.items(): django/trunk/docs/generic_views.txt
r3022 r3039 251 251 the view's template. See the `RequestContext docs`_. 252 252 253 * ``template_object_name``: Designates the name of the template variable 254 to use in the template context. By default, this is ``'object'``. The 255 view will append ``'_list'`` to the value of this parameter in 256 determining the variable's name. 257 258 * ``make_object_list``: A boolean specifying whether to retrieve the full 259 list of objects for this year and pass those to the template. If ``True``, 260 this list of objects will be made available to the template as 261 ``object_list``. (The name ``object_list`` may be different; see the docs 262 for ``object_list`` in the "Template context" section below.) By default, 263 this is ``False``. 264 253 265 * ``mimetype``: The MIME type to use for the resulting document. Defaults 254 266 to the value of the ``DEFAULT_MIME_TYPE`` setting. … … 266 278 months that have objects available in the given year, according to 267 279 ``queryset``, in ascending order. 280 268 281 * ``year``: The given year, as a four-character string. 282 283 * ``object_list``: If the ``make_object_list`` parameter is ``True``, this 284 will be set to a list of objects available for the given year, ordered by 285 the date field. This variable's name depends on the 286 ``template_object_name`` parameter, which is ``'object'`` by default. If 287 ``template_object_name`` is ``'foo'``, this variable's name will be 288 ``foo_list``. 289 290 If ``make_object_list`` is ``False``, ``object_list`` will be passed to 291 the template as an empty list. 269 292 270 293 ``django.views.generic.date_based.archive_month``
