From d40781952b1f47cc9d854d025d95e5dcbebb19e3 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 15 Apr 2006 20:12:19 +0000 Subject: [PATCH] magic-removal: Fixed #1643 -- Updated generic views for template extension change git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2701 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/generic/create_update.py | 12 ++++++------ django/views/generic/date_based.py | 20 ++++++++++---------- django/views/generic/list_detail.py | 8 ++++---- docs/generic_views.txt | 18 +++++++++--------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py index 5637ca5015..9f0f7a416d 100644 --- a/django/views/generic/create_update.py +++ b/django/views/generic/create_update.py @@ -14,7 +14,7 @@ def create_object(request, model, template_name=None, """ Generic object-creation function. - Templates: ``/_form`` + Templates: ``/_form.html`` Context: form the form wrapper for the object @@ -57,7 +57,7 @@ def create_object(request, model, template_name=None, # Create the FormWrapper, template, context, response form = forms.FormWrapper(manipulator, new_data, errors) if not template_name: - template_name = "%s/%s_form" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_form.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { 'form': form, @@ -77,7 +77,7 @@ def update_object(request, model, object_id=None, slug=None, """ Generic object-update function. - Templates: ``/_form`` + Templates: ``/_form.html`` Context: form the form wrapper for the object @@ -127,7 +127,7 @@ def update_object(request, model, object_id=None, slug=None, form = forms.FormWrapper(manipulator, new_data, errors) if not template_name: - template_name = "%s/%s_form" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_form.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { 'form': form, @@ -153,7 +153,7 @@ def delete_object(request, model, post_delete_redirect, fetched using GET; for safty, deletion will only be performed if this view is POSTed. - Templates: ``/_confirm_delete`` + Templates: ``/_confirm_delete.html`` Context: object the original object being deleted @@ -182,7 +182,7 @@ def delete_object(request, model, post_delete_redirect, return HttpResponseRedirect(post_delete_redirect) else: if not template_name: - template_name = "%s/%s_confirm_delete" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_confirm_delete.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { template_object_name: object, diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py index 5946f720be..61ee214f44 100644 --- a/django/views/generic/date_based.py +++ b/django/views/generic/date_based.py @@ -10,7 +10,7 @@ def archive_index(request, queryset, date_field, num_latest=15, """ Generic top-level archive of date-based objects. - Templates: ``/_archive`` + Templates: ``/_archive.html`` Context: date_list List of years @@ -29,7 +29,7 @@ def archive_index(request, queryset, date_field, num_latest=15, latest = None if not template_name: - template_name = "%s/%s_archive" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_archive.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { 'date_list' : date_list, @@ -48,7 +48,7 @@ def archive_year(request, year, queryset, date_field, template_name=None, """ Generic yearly archive view. - Templates: ``/_archive_year`` + Templates: ``/_archive_year.html`` Context: date_list List of months in this year with objects @@ -65,7 +65,7 @@ def archive_year(request, year, queryset, date_field, template_name=None, if not date_list and not allow_empty: raise Http404 if not template_name: - template_name = "%s/%s_archive_year" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_archive_year.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { 'date_list': date_list, @@ -85,7 +85,7 @@ def archive_month(request, year, month, queryset, date_field, """ Generic monthly archive view. - Templates: ``/_archive_month`` + Templates: ``/_archive_month.html`` Context: month: (date) this month @@ -117,7 +117,7 @@ def archive_month(request, year, month, queryset, date_field, if not object_list and not allow_empty: raise Http404 if not template_name: - template_name = "%s/%s_archive_month" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_archive_month.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { '%s_list' % template_object_name: object_list, @@ -139,7 +139,7 @@ def archive_day(request, year, month, day, queryset, date_field, """ Generic daily archive view. - Templates: ``/_archive_day`` + Templates: ``/_archive_day.html`` Context: object_list: list of objects published that day @@ -167,7 +167,7 @@ def archive_day(request, year, month, day, queryset, date_field, if not allow_empty and not object_list: raise Http404 if not template_name: - template_name = "%s/%s_archive_day" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_archive_day.html" % (model._meta.app_label, model._meta.object_name.lower()) t = template_loader.get_template(template_name) c = RequestContext(request, { '%s_list' % template_object_name: object_list, @@ -202,7 +202,7 @@ def object_detail(request, year, month, day, queryset, date_field, """ Generic detail view from year/month/day/slug or year/month/day/id structure. - Templates: ``/_detail`` + Templates: ``/_detail.html`` Context: object: the object to be detailed @@ -231,7 +231,7 @@ def object_detail(request, year, month, day, queryset, date_field, except ObjectDoesNotExist: raise Http404, "No %s found for" % model._meta.verbose_name if not template_name: - template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_detail.html" % (model._meta.app_label, model._meta.object_name.lower()) if template_name_field: template_name_list = [getattr(obj, template_name_field), template_name] t = template_loader.select_template(template_name_list) diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py index 6184a57603..68a1e73b07 100644 --- a/django/views/generic/list_detail.py +++ b/django/views/generic/list_detail.py @@ -10,7 +10,7 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False, """ Generic list of objects. - Templates: ``/_list`` + Templates: ``/_list.html`` Context: object_list list of objects @@ -71,7 +71,7 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False, else: c[key] = value if not template_name: - template_name = "%s/%s_list" % (model._meta.app_label, model._meta.object_name.lower()) + 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)) @@ -82,7 +82,7 @@ def object_detail(request, queryset, object_id=None, slug=None, """ Generic list of objects. - Templates: ``/_detail`` + Templates: ``/_detail.html`` Context: object the object @@ -99,7 +99,7 @@ def object_detail(request, queryset, object_id=None, slug=None, except ObjectDoesNotExist: raise Http404, "No %s found matching the query" % (model._meta.verbose_name) if not template_name: - template_name = "%s/%s_detail" % (model._meta.app_label, model._meta.object_name.lower()) + template_name = "%s/%s_detail.html" % (model._meta.app_label, model._meta.object_name.lower()) if template_name_field: template_name_list = [getattr(obj, template_name_field), template_name] t = template_loader.select_template(template_name_list) diff --git a/docs/generic_views.txt b/docs/generic_views.txt index b6a51e0618..23e3c4700c 100644 --- a/docs/generic_views.txt +++ b/docs/generic_views.txt @@ -146,7 +146,7 @@ The date-based generic functions are: an empty index page. ``False`` is default. ======================= ================================================= - Uses the template ``/_archive`` by default, where: + Uses the template ``/_archive.html`` by default, where: * ```` is your model's name in all lowercase. For a model ``StaffMember``, that'd be ``staffmember``. @@ -168,7 +168,7 @@ The date-based generic functions are: Takes an optional ``allow_empty`` parameter, as ``archive_index``. - Uses the template ``/_archive_year`` by default. + Uses the template ``/_archive_year.html`` by default. Has the following template context: @@ -193,7 +193,7 @@ The date-based generic functions are: ``template_object_name`` parameter, which designates the name of the template variable to use. Default is ``'object'``. - Uses the template ``/_archive_month`` by default. + Uses the template ``/_archive_month.html`` by default. Has the following template context: @@ -225,7 +225,7 @@ The date-based generic functions are: ``template_object_name`` parameter, which designates the name of the template variable to use. Default is ``'object'``. - Uses the template ``/_archive_day`` by default. + Uses the template ``/_archive_day.html`` by default. Has the following template context: @@ -307,7 +307,7 @@ Individual views are: is ``'object'``. ======================== ================================================= - Uses the template ``/`` by default. + Uses the template ``/.html`` by default. Has the following template context: @@ -364,9 +364,9 @@ The create/update/delete views are: be interpolated against the object's field attributes. For example, you could use ``post_save_redirect="/polls/%(slug)s/"``. - Uses the template ``/_form`` by default. This is the - same template as the ``update_object`` view below. Your template can tell - the difference by the presence or absence of ``{{ object }}`` in the + Uses the template ``/_form.html`` by default. This + is the same template as the ``update_object`` view below. Your template can + tell the difference by the presence or absence of ``{{ object }}`` in the context. Has the following template context: @@ -390,7 +390,7 @@ The create/update/delete views are: ``template_object_name`` parameter, which designates the name of the template variable to use. Default is ``'object'``. - Uses the template ``/_form`` by default. + Uses the template ``/_form.html`` by default. Has the following template context: