Loading django/views/generic/date_based.py +14 −12 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ import datetime, time def archive_index(request, queryset, date_field, num_latest=15, template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None): extra_context={}, allow_empty=False, context_processors=None, mimetype=None): """ Generic top-level archive of date-based objects. Loading Loading @@ -40,11 +41,11 @@ def archive_index(request, queryset, date_field, num_latest=15, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_year(request, year, queryset, date_field, template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None): context_processors=None, mimetype=None): """ Generic yearly archive view. Loading Loading @@ -78,12 +79,12 @@ def archive_year(request, year, queryset, date_field, template_name=None, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_month(request, year, month, queryset, date_field, month_format='%b', template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic monthly archive view. Loading Loading @@ -134,12 +135,12 @@ def archive_month(request, year, month, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_week(request, year, week, queryset, date_field, template_name=None, template_loader=loader, extra_context={}, allow_empty=True, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic weekly archive view. Loading Loading @@ -181,12 +182,13 @@ def archive_week(request, year, week, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_day(request, year, month, day, queryset, date_field, month_format='%b', day_format='%d', template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None, template_object_name='object'): context_processors=None, template_object_name='object', mimetype=None): """ Generic daily archive view. Loading Loading @@ -233,7 +235,7 @@ def archive_day(request, year, month, day, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_today(request, **kwargs): """ Loading @@ -251,7 +253,7 @@ def object_detail(request, year, month, day, queryset, date_field, month_format='%b', day_format='%d', object_id=None, slug=None, slug_field=None, template_name=None, template_name_field=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic detail view from year/month/day/slug or year/month/day/id structure. Loading Loading @@ -300,6 +302,6 @@ def object_detail(request, year, month, day, queryset, date_field, c[key] = value() else: c[key] = value response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c), mimetype=mimetype) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name)) return response django/views/generic/list_detail.py +6 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ from django.core.exceptions import ObjectDoesNotExist def object_list(request, queryset, paginate_by=None, allow_empty=False, template_name=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): extra_context={}, context_processors=None, template_object_name='object', mimetype=None): """ Generic list of objects. Loading Loading @@ -73,12 +74,13 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False, model = queryset.model template_name = "%s/%s_list.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def object_detail(request, queryset, object_id=None, slug=None, slug_field=None, template_name=None, template_name_field=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): context_processors=None, template_object_name='object', mimetype=None): """ Generic list of objects. Loading Loading @@ -113,6 +115,6 @@ def object_detail(request, queryset, object_id=None, slug=None, c[key] = value() else: c[key] = value response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c), mimetype=mimetype) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name)) return response docs/generic_views.txt +24 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,9 @@ a date in the *future* are not included. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -247,6 +250,9 @@ with a date in the *future* are not displayed. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -314,6 +320,9 @@ date in the *future* are not displayed. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -387,6 +396,9 @@ in the *future* are not displayed. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -463,6 +475,9 @@ a 404 error, regardless of whether any objects exist for future days. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -563,6 +578,9 @@ A page representing an individual object. * ``template_object_name``: Designates the name of the template variable to use in the template context. By default, this is ``'object'``. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -627,6 +645,9 @@ A page representing a list of objects. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -717,6 +738,9 @@ A page representing an individual object. * ``template_object_name``: Designates the name of the template variable to use in the template context. By default, this is ``'object'``. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading
django/views/generic/date_based.py +14 −12 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ import datetime, time def archive_index(request, queryset, date_field, num_latest=15, template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None): extra_context={}, allow_empty=False, context_processors=None, mimetype=None): """ Generic top-level archive of date-based objects. Loading Loading @@ -40,11 +41,11 @@ def archive_index(request, queryset, date_field, num_latest=15, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_year(request, year, queryset, date_field, template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None): context_processors=None, mimetype=None): """ Generic yearly archive view. Loading Loading @@ -78,12 +79,12 @@ def archive_year(request, year, queryset, date_field, template_name=None, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_month(request, year, month, queryset, date_field, month_format='%b', template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic monthly archive view. Loading Loading @@ -134,12 +135,12 @@ def archive_month(request, year, month, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_week(request, year, week, queryset, date_field, template_name=None, template_loader=loader, extra_context={}, allow_empty=True, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic weekly archive view. Loading Loading @@ -181,12 +182,13 @@ def archive_week(request, year, week, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_day(request, year, month, day, queryset, date_field, month_format='%b', day_format='%d', template_name=None, template_loader=loader, extra_context={}, allow_empty=False, context_processors=None, template_object_name='object'): context_processors=None, template_object_name='object', mimetype=None): """ Generic daily archive view. Loading Loading @@ -233,7 +235,7 @@ def archive_day(request, year, month, day, queryset, date_field, c[key] = value() else: c[key] = value return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def archive_today(request, **kwargs): """ Loading @@ -251,7 +253,7 @@ def object_detail(request, year, month, day, queryset, date_field, month_format='%b', day_format='%d', object_id=None, slug=None, slug_field=None, template_name=None, template_name_field=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): template_object_name='object', mimetype=None): """ Generic detail view from year/month/day/slug or year/month/day/id structure. Loading Loading @@ -300,6 +302,6 @@ def object_detail(request, year, month, day, queryset, date_field, c[key] = value() else: c[key] = value response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c), mimetype=mimetype) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name)) return response
django/views/generic/list_detail.py +6 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ from django.core.exceptions import ObjectDoesNotExist def object_list(request, queryset, paginate_by=None, allow_empty=False, template_name=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): extra_context={}, context_processors=None, template_object_name='object', mimetype=None): """ Generic list of objects. Loading Loading @@ -73,12 +74,13 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False, model = queryset.model template_name = "%s/%s_list.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) return HttpResponse(t.render(c)) return HttpResponse(t.render(c), mimetype=mimetype) def object_detail(request, queryset, object_id=None, slug=None, slug_field=None, template_name=None, template_name_field=None, template_loader=loader, extra_context={}, context_processors=None, template_object_name='object'): context_processors=None, template_object_name='object', mimetype=None): """ Generic list of objects. Loading Loading @@ -113,6 +115,6 @@ def object_detail(request, queryset, object_id=None, slug=None, c[key] = value() else: c[key] = value response = HttpResponse(t.render(c)) response = HttpResponse(t.render(c), mimetype=mimetype) populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name)) return response
docs/generic_views.txt +24 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,9 @@ a date in the *future* are not included. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -247,6 +250,9 @@ with a date in the *future* are not displayed. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -314,6 +320,9 @@ date in the *future* are not displayed. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -387,6 +396,9 @@ in the *future* are not displayed. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -463,6 +475,9 @@ a 404 error, regardless of whether any objects exist for future days. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -563,6 +578,9 @@ A page representing an individual object. * ``template_object_name``: Designates the name of the template variable to use in the template context. By default, this is ``'object'``. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -627,6 +645,9 @@ A page representing a list of objects. view will append ``'_list'`` to the value of this parameter in determining the variable's name. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading Loading @@ -717,6 +738,9 @@ A page representing an individual object. * ``template_object_name``: Designates the name of the template variable to use in the template context. By default, this is ``'object'``. * ``mimetype``: The MIME type to use for the resulting document. Defaults to the value of the ``DEFAULT_MIME_TYPE`` setting. **Template name:** If ``template_name`` isn't specified, this view will use the template Loading