mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
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
This commit is contained in:
parent
6442fd27bc
commit
d40781952b
@ -14,7 +14,7 @@ def create_object(request, model, template_name=None,
|
||||
"""
|
||||
Generic object-creation function.
|
||||
|
||||
Templates: ``<app_label>/<model_name>_form``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_form``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_confirm_delete``
|
||||
Templates: ``<app_label>/<model_name>_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,
|
||||
|
@ -10,7 +10,7 @@ def archive_index(request, queryset, date_field, num_latest=15,
|
||||
"""
|
||||
Generic top-level archive of date-based objects.
|
||||
|
||||
Templates: ``<app_label>/<model_name>_archive``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_archive_year``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_archive_month``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_archive_day``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_detail``
|
||||
Templates: ``<app_label>/<model_name>_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)
|
||||
|
@ -10,7 +10,7 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False,
|
||||
"""
|
||||
Generic list of objects.
|
||||
|
||||
Templates: ``<app_label>/<model_name>_list``
|
||||
Templates: ``<app_label>/<model_name>_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: ``<app_label>/<model_name>_detail``
|
||||
Templates: ``<app_label>/<model_name>_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)
|
||||
|
@ -146,7 +146,7 @@ The date-based generic functions are:
|
||||
an empty index page. ``False`` is default.
|
||||
======================= =================================================
|
||||
|
||||
Uses the template ``<app_label>/<model_name>_archive`` by default, where:
|
||||
Uses the template ``<app_label>/<model_name>_archive.html`` by default, where:
|
||||
|
||||
* ``<model_name>`` 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 ``<app_label>/<model_name>_archive_year`` by default.
|
||||
Uses the template ``<app_label>/<model_name>_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 ``<app_label>/<model_name>_archive_month`` by default.
|
||||
Uses the template ``<app_label>/<model_name>_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 ``<app_label>/<model_name>_archive_day`` by default.
|
||||
Uses the template ``<app_label>/<model_name>_archive_day.html`` by default.
|
||||
|
||||
Has the following template context:
|
||||
|
||||
@ -307,7 +307,7 @@ Individual views are:
|
||||
is ``'object'``.
|
||||
======================== =================================================
|
||||
|
||||
Uses the template ``<app_label>/<module_name_list>`` by default.
|
||||
Uses the template ``<app_label>/<module_name_list>.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 ``<app_label>/<model_name>_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 ``<app_label>/<model_name>_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 ``<app_label>/<model_name>_form`` by default.
|
||||
Uses the template ``<app_label>/<model_name>_form.html`` by default.
|
||||
|
||||
Has the following template context:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user