mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
magic-removal: Fixed #500 -- Removed TEMPLATE_FILE_EXTENSION setting so that template loading requires you to give the full filename, including extension. This applies everywhere, even in the 'extends' and 'include' template tags.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2700 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
39d42d4861
commit
6442fd27bc
@ -102,9 +102,6 @@ INSTALLED_APPS = ()
|
||||
# List of locations of the template source files, in search order.
|
||||
TEMPLATE_DIRS = ()
|
||||
|
||||
# Extension on all templates.
|
||||
TEMPLATE_FILE_EXTENSION = '.html'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
# See the comments in django/core/template/loader.py for interface
|
||||
# documentation.
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{% trans 'Page not found' %}{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans "Home" %}</a> › {% trans "Server error" %}</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base" %}
|
||||
{% extends "admin/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n admin_modify adminmedia %}
|
||||
{% block extrahead %}{{ block.super }}
|
||||
<script type="text/javascript" src="../../../jsi18n/"></script>
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load adminmedia admin_list i18n %}
|
||||
{% block stylesheet %}{% admin_media_prefix %}css/changelists.css{% endblock %}
|
||||
{% block bodyclass %}change-list{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block userlinks %}<a href="../../../../doc/">{% trans 'Documentation' %}</a> / <a href="../../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
{% block breadcrumbs %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/login.css{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block userlinks %}<a href="../../../../doc/">{% trans 'Documentation' %}</a> / <a href="../../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
{% block breadcrumbs %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
|
||||
{% block breadcrumbs %}{% load i18n %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> › <a href="../">{% trans "Documentation" %}</a> › {% trans "Bookmarklets" %}</div>{% endblock %}
|
||||
{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> › Documentation</div>{% endblock %}
|
||||
{% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> › Documentation</div>{% endblock %}
|
||||
{% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
{% block extrahead %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block coltype %}colSM{% endblock %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Models</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> › <a href="../../">Documentation</a> › Templates › {{ name }}</div>{% endblock %}
|
||||
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block coltype %}colSM{% endblock %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › filters</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block coltype %}colSM{% endblock %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Tags</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> › <a href="../../">Documentation</a> › <a href="../">Views</a> › {{ name }}</div>{% endblock %}
|
||||
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block coltype %}colSM{% endblock %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> › <a href="../">Documentation</a> › Views</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a></div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password change' %}</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
{% block userlinks %}<a href="../doc/">{% trans 'Documentation' %}</a> / {% trans 'Change password' %} / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password change' %}</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password reset' %}</div>{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "admin/base_site" %}
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> › {% trans 'Password reset' %}</div>{% endblock %}
|
||||
|
@ -1 +1 @@
|
||||
{% include "widget/foreign" %}
|
||||
{% include "widget/foreign.html" %}
|
||||
|
@ -1 +1 @@
|
||||
{% include "widget/foreign" %}
|
||||
{% include "widget/foreign.html" %}
|
||||
|
@ -65,7 +65,7 @@ def pagination(cl):
|
||||
'ALL_VAR': ALL_VAR,
|
||||
'1': 1,
|
||||
}
|
||||
pagination = register.inclusion_tag('admin/pagination')(pagination)
|
||||
pagination = register.inclusion_tag('admin/pagination.html')(pagination)
|
||||
|
||||
def result_headers(cl):
|
||||
lookup_opts = cl.lookup_opts
|
||||
@ -185,7 +185,7 @@ def result_list(cl):
|
||||
return {'cl': cl,
|
||||
'result_headers': list(result_headers(cl)),
|
||||
'results': list(results(cl))}
|
||||
result_list = register.inclusion_tag("admin/change_list_results")(result_list)
|
||||
result_list = register.inclusion_tag("admin/change_list_results.html")(result_list)
|
||||
|
||||
def date_hierarchy(cl):
|
||||
if cl.lookup_opts.admin.date_hierarchy:
|
||||
@ -245,7 +245,7 @@ def date_hierarchy(cl):
|
||||
'title': year.year
|
||||
} for year in years]
|
||||
}
|
||||
date_hierarchy = register.inclusion_tag('admin/date_hierarchy')(date_hierarchy)
|
||||
date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)
|
||||
|
||||
def search_form(cl):
|
||||
return {
|
||||
@ -253,12 +253,12 @@ def search_form(cl):
|
||||
'show_result_count': cl.result_count != cl.full_result_count and not cl.opts.one_to_one_field,
|
||||
'search_var': SEARCH_VAR
|
||||
}
|
||||
search_form = register.inclusion_tag('admin/search_form')(search_form)
|
||||
search_form = register.inclusion_tag('admin/search_form.html')(search_form)
|
||||
|
||||
def filter(cl, spec):
|
||||
return {'title': spec.title(), 'choices' : list(spec.choices(cl))}
|
||||
filter = register.inclusion_tag('admin/filter')(filter)
|
||||
filter = register.inclusion_tag('admin/filter.html')(filter)
|
||||
|
||||
def filters(cl):
|
||||
return {'cl': cl}
|
||||
filters = register.inclusion_tag('admin/filters')(filters)
|
||||
filters = register.inclusion_tag('admin/filters.html')(filters)
|
||||
|
@ -35,7 +35,7 @@ def submit_row(context):
|
||||
'show_save_and_continue': not is_popup and context['has_change_permission'],
|
||||
'show_save': True
|
||||
}
|
||||
submit_row = register.inclusion_tag('admin/submit_line', takes_context=True)(submit_row)
|
||||
submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)
|
||||
|
||||
def field_label(bound_field):
|
||||
class_names = []
|
||||
@ -64,7 +64,7 @@ class FieldWidgetNode(template.Node):
|
||||
if not cls.nodelists.has_key(klass):
|
||||
try:
|
||||
field_class_name = klass.__name__
|
||||
template_name = "widget/%s" % class_name_to_underscored(field_class_name)
|
||||
template_name = "widget/%s.html" % class_name_to_underscored(field_class_name)
|
||||
nodelist = loader.get_template(template_name).nodelist
|
||||
except template.TemplateDoesNotExist:
|
||||
super_klass = bool(klass.__bases__) and klass.__bases__[0] or None
|
||||
@ -72,7 +72,7 @@ class FieldWidgetNode(template.Node):
|
||||
nodelist = cls.get_nodelist(super_klass)
|
||||
else:
|
||||
if not cls.default:
|
||||
cls.default = loader.get_template("widget/default").nodelist
|
||||
cls.default = loader.get_template("widget/default.html").nodelist
|
||||
nodelist = cls.default
|
||||
|
||||
cls.nodelists[klass] = nodelist
|
||||
@ -126,7 +126,7 @@ class TabularBoundRelatedObject(BoundRelatedObject):
|
||||
self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url')
|
||||
|
||||
def template_name(self):
|
||||
return "admin/edit_inline_tabular"
|
||||
return "admin/edit_inline_tabular.html"
|
||||
|
||||
class StackedBoundRelatedObject(BoundRelatedObject):
|
||||
def __init__(self, related_object, field_mapping, original):
|
||||
@ -138,7 +138,7 @@ class StackedBoundRelatedObject(BoundRelatedObject):
|
||||
self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url')
|
||||
|
||||
def template_name(self):
|
||||
return "admin/edit_inline_stacked"
|
||||
return "admin/edit_inline_stacked.html"
|
||||
|
||||
class EditInlineNode(template.Node):
|
||||
def __init__(self, rel_var):
|
||||
@ -229,4 +229,4 @@ def admin_field_line(context, argument_val):
|
||||
'bound_fields': bound_fields,
|
||||
'class_names': " ".join(class_names),
|
||||
}
|
||||
admin_field_line = register.inclusion_tag('admin/field_line', takes_context=True)(admin_field_line)
|
||||
admin_field_line = register.inclusion_tag('admin/field_line.html', takes_context=True)(admin_field_line)
|
||||
|
@ -19,7 +19,7 @@ def _display_login_form(request, error_message=''):
|
||||
post_data = _encode_post_data(request.POST)
|
||||
else:
|
||||
post_data = _encode_post_data({})
|
||||
return render_to_response('admin/login', {
|
||||
return render_to_response('admin/login.html', {
|
||||
'title': _('Log in'),
|
||||
'app_path': request.path,
|
||||
'post_data': post_data,
|
||||
|
@ -17,13 +17,13 @@ MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
|
||||
def doc_index(request):
|
||||
if not utils.docutils_is_available:
|
||||
return missing_docutils_page(request)
|
||||
return render_to_response('admin_doc/index', context_instance=RequestContext(request))
|
||||
return render_to_response('admin_doc/index.html', context_instance=RequestContext(request))
|
||||
doc_index = staff_member_required(doc_index)
|
||||
|
||||
def bookmarklets(request):
|
||||
# Hack! This couples this view to the URL it lives at.
|
||||
admin_root = request.path[:-len('doc/bookmarklets/')]
|
||||
return render_to_response('admin_doc/bookmarklets', {
|
||||
return render_to_response('admin_doc/bookmarklets.html', {
|
||||
'admin_url': "%s://%s%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', get_host(request), admin_root),
|
||||
}, context_instance=RequestContext(request))
|
||||
bookmarklets = staff_member_required(bookmarklets)
|
||||
@ -56,7 +56,7 @@ def template_tag_index(request):
|
||||
'library': tag_library,
|
||||
})
|
||||
|
||||
return render_to_response('admin_doc/template_tag_index', {'tags': tags}, context_instance=RequestContext(request))
|
||||
return render_to_response('admin_doc/template_tag_index.html', {'tags': tags}, context_instance=RequestContext(request))
|
||||
template_tag_index = staff_member_required(template_tag_index)
|
||||
|
||||
def template_filter_index(request):
|
||||
@ -86,7 +86,7 @@ def template_filter_index(request):
|
||||
'meta': metadata,
|
||||
'library': tag_library,
|
||||
})
|
||||
return render_to_response('admin_doc/template_filter_index', {'filters': filters}, context_instance=RequestContext(request))
|
||||
return render_to_response('admin_doc/template_filter_index.html', {'filters': filters}, context_instance=RequestContext(request))
|
||||
template_filter_index = staff_member_required(template_filter_index)
|
||||
|
||||
def view_index(request):
|
||||
@ -110,7 +110,7 @@ def view_index(request):
|
||||
'site': Site.objects.get(pk=settings_mod.SITE_ID),
|
||||
'url': simplify_regex(regex),
|
||||
})
|
||||
return render_to_response('admin_doc/view_index', {'views': views}, context_instance=RequestContext(request))
|
||||
return render_to_response('admin_doc/view_index.html', {'views': views}, context_instance=RequestContext(request))
|
||||
view_index = staff_member_required(view_index)
|
||||
|
||||
def view_detail(request, view):
|
||||
@ -129,7 +129,7 @@ def view_detail(request, view):
|
||||
body = utils.parse_rst(body, 'view', 'view:' + view)
|
||||
for key in metadata:
|
||||
metadata[key] = utils.parse_rst(metadata[key], 'model', 'view:' + view)
|
||||
return render_to_response('admin_doc/view_detail', {
|
||||
return render_to_response('admin_doc/view_detail.html', {
|
||||
'name': view,
|
||||
'summary': title,
|
||||
'body': body,
|
||||
@ -142,7 +142,7 @@ def model_index(request):
|
||||
return missing_docutils_page(request)
|
||||
|
||||
m_list = [m._meta for m in models.get_models()]
|
||||
return render_to_response('admin_doc/model_index', {'models': m_list}, context_instance=RequestContext(request))
|
||||
return render_to_response('admin_doc/model_index.html', {'models': m_list}, context_instance=RequestContext(request))
|
||||
model_index = staff_member_required(model_index)
|
||||
|
||||
def model_detail(request, app_label, model_name):
|
||||
@ -214,7 +214,7 @@ def model_detail(request, app_label, model_name):
|
||||
'verbose' : utils.parse_rst("number of " + verbose , 'model', 'model:' + opts.module_name),
|
||||
})
|
||||
|
||||
return render_to_response('admin_doc/model_detail', {
|
||||
return render_to_response('admin_doc/model_detail.html', {
|
||||
'name': '%s.%s' % (opts.app_label, opts.object_name),
|
||||
'summary': "Fields on %s objects" % opts.object_name,
|
||||
'description': model.__doc__,
|
||||
@ -236,7 +236,7 @@ def template_detail(request, template):
|
||||
'site': Site.objects.get(pk=settings_mod.SITE_ID),
|
||||
'order': list(settings_mod.TEMPLATE_DIRS).index(dir),
|
||||
})
|
||||
return render_to_response('admin_doc/template_detail', {
|
||||
return render_to_response('admin_doc/template_detail.html', {
|
||||
'name': template,
|
||||
'templates': templates,
|
||||
}, context_instance=RequestContext(request))
|
||||
@ -248,7 +248,7 @@ template_detail = staff_member_required(template_detail)
|
||||
|
||||
def missing_docutils_page(request):
|
||||
"""Display an error message for people without docutils"""
|
||||
return render_to_response('admin_doc/missing_docutils')
|
||||
return render_to_response('admin_doc/missing_docutils.html')
|
||||
|
||||
def load_all_installed_template_libraries():
|
||||
# Load/register all template tag libraries from installed apps.
|
||||
|
@ -218,12 +218,12 @@ def render_change_form(model, manipulator, context, add=False, change=False, for
|
||||
}
|
||||
context.update(extra_context)
|
||||
return render_to_response([
|
||||
"admin/%s/%s/change_form" % (app_label, opts.object_name.lower()),
|
||||
"admin/%s/change_form" % app_label,
|
||||
"admin/change_form"], context_instance=context)
|
||||
"admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()),
|
||||
"admin/%s/change_form.html" % app_label,
|
||||
"admin/change_form.html"], context_instance=context)
|
||||
|
||||
def index(request):
|
||||
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
|
||||
return render_to_response('admin/index.html', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
|
||||
index = staff_member_required(never_cache(index))
|
||||
|
||||
def add_stage(request, app_label, model_name, show_delete=False, form_url='', post_url=None, post_url_continue='../%s/', object_id_override=None):
|
||||
@ -515,9 +515,9 @@ def delete_stage(request, app_label, model_name, object_id):
|
||||
"perms_lacking": perms_needed,
|
||||
"opts": model._meta,
|
||||
}
|
||||
return render_to_response(["admin/%s/%s/delete_confirmation" % (app_label, opts.object_name.lower() ),
|
||||
"admin/%s/delete_confirmation" % app_label ,
|
||||
"admin/delete_confirmation"], extra_context, context_instance=template.RequestContext(request))
|
||||
return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
|
||||
"admin/%s/delete_confirmation.html" % app_label ,
|
||||
"admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
|
||||
delete_stage = staff_member_required(never_cache(delete_stage))
|
||||
|
||||
def history(request, app_label, model_name, object_id):
|
||||
@ -535,9 +535,9 @@ def history(request, app_label, model_name, object_id):
|
||||
'module_name': capfirst(model._meta.verbose_name_plural),
|
||||
'object': obj,
|
||||
}
|
||||
return render_to_response(["admin/%s/%s/object_history" % (app_label, model._meta.object_name.lower()),
|
||||
"admin/%s/object_history" % app_label ,
|
||||
"admin/object_history"], extra_context, context_instance=template.RequestContext(request))
|
||||
return render_to_response(["admin/%s/%s/object_history.html" % (app_label, model._meta.object_name.lower()),
|
||||
"admin/%s/object_history.html" % app_label ,
|
||||
"admin/object_history.html"], extra_context, context_instance=template.RequestContext(request))
|
||||
history = staff_member_required(never_cache(history))
|
||||
|
||||
class ChangeList(object):
|
||||
@ -734,7 +734,7 @@ def change_list(request, app_label, model_name):
|
||||
'cl': cl,
|
||||
})
|
||||
c.update({'has_add_permission': c['perms'][app_label][cl.opts.get_add_permission()]}),
|
||||
return render_to_response(['admin/%s/%s/change_list' % (app_label, cl.opts.object_name.lower()),
|
||||
'admin/%s/change_list' % app_label,
|
||||
'admin/change_list'], context_instance=c)
|
||||
return render_to_response(['admin/%s/%s/change_list.html' % (app_label, cl.opts.object_name.lower()),
|
||||
'admin/%s/change_list.html' % app_label,
|
||||
'admin/change_list.html'], context_instance=c)
|
||||
change_list = staff_member_required(never_cache(change_list))
|
||||
|
@ -23,7 +23,7 @@ def template_validator(request):
|
||||
errors = manipulator.get_validation_errors(new_data)
|
||||
if not errors:
|
||||
request.user.add_message('The template is valid.')
|
||||
return render_to_response('admin/template_validator', {
|
||||
return render_to_response('admin/template_validator.html', {
|
||||
'title': 'Template validator',
|
||||
'form': forms.FormWrapper(manipulator, new_data, errors),
|
||||
}, context_instance=template.RequestContext(request))
|
||||
|
@ -75,7 +75,7 @@ class PasswordResetForm(forms.Manipulator):
|
||||
domain = current_site.domain
|
||||
else:
|
||||
site_name = domain = domain_override
|
||||
t = loader.get_template('registration/password_reset_email')
|
||||
t = loader.get_template('registration/password_reset_email.html')
|
||||
c = {
|
||||
'new_password': new_pass,
|
||||
'email': self.user_cache.email,
|
||||
|
@ -25,7 +25,7 @@ def login(request):
|
||||
else:
|
||||
errors = {}
|
||||
request.session.set_test_cookie()
|
||||
return render_to_response('registration/login', {
|
||||
return render_to_response('registration/login.html', {
|
||||
'form': forms.FormWrapper(manipulator, request.POST, errors),
|
||||
REDIRECT_FIELD_NAME: redirect_to,
|
||||
'site_name': Site.objects.get_current().name,
|
||||
@ -36,7 +36,7 @@ def logout(request, next_page=None):
|
||||
try:
|
||||
del request.session[SESSION_KEY]
|
||||
except KeyError:
|
||||
return render_to_response('registration/logged_out', {'title': 'Logged out'}, context_instance=RequestContext(request))
|
||||
return render_to_response('registration/logged_out.html', {'title': 'Logged out'}, context_instance=RequestContext(request))
|
||||
else:
|
||||
# Redirect to this page until the session has been cleared.
|
||||
return HttpResponseRedirect(next_page or request.path)
|
||||
@ -61,11 +61,11 @@ def password_reset(request, is_admin_site=False):
|
||||
else:
|
||||
form.save()
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('registration/password_reset_form', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
return render_to_response('registration/password_reset_form.html', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def password_reset_done(request):
|
||||
return render_to_response('registration/password_reset_done', context_instance=RequestContext(request))
|
||||
return render_to_response('registration/password_reset_done.html', context_instance=RequestContext(request))
|
||||
|
||||
def password_change(request):
|
||||
new_data, errors = {}, {}
|
||||
@ -76,9 +76,9 @@ def password_change(request):
|
||||
if not errors:
|
||||
form.save(new_data)
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('registration/password_change_form', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
return render_to_response('registration/password_change_form.html', {'form': forms.FormWrapper(form, new_data, errors)},
|
||||
context_instance=RequestContext(request))
|
||||
password_change = login_required(password_change)
|
||||
|
||||
def password_change_done(request):
|
||||
return render_to_response('registration/password_change_done', context_instance=RequestContext(request))
|
||||
return render_to_response('registration/password_change_done.html', context_instance=RequestContext(request))
|
||||
|
@ -232,7 +232,7 @@ def post_comment(request):
|
||||
return field_list
|
||||
comment = errors and '' or manipulator.get_comment(new_data)
|
||||
comment_form = CommentFormWrapper(manipulator, new_data, errors, rating_choices)
|
||||
return render_to_response('comments/preview', {
|
||||
return render_to_response('comments/preview.html', {
|
||||
'comment': comment,
|
||||
'comment_form': comment_form,
|
||||
'options': options,
|
||||
@ -300,7 +300,7 @@ def post_free_comment(request):
|
||||
errors = manipulator.get_validation_errors(new_data)
|
||||
if errors or request.POST.has_key('preview'):
|
||||
comment = errors and '' or manipulator.get_comment(new_data)
|
||||
return render_to_response('comments/free_preview', {
|
||||
return render_to_response('comments/free_preview.html', {
|
||||
'comment': comment,
|
||||
'comment_form': forms.FormWrapper(manipulator, new_data, errors),
|
||||
'options': options,
|
||||
@ -337,4 +337,4 @@ def comment_was_posted(request):
|
||||
obj = content_type.get_object_for_this_type(pk=object_id)
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
return render_to_response('comments/posted', {'object': obj}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/posted.html', {'object': obj}, context_instance=RequestContext(request))
|
||||
|
@ -26,4 +26,4 @@ def vote(request, comment_id, vote):
|
||||
karma.vote(request.user.id, comment_id, rating)
|
||||
# Reload comment to ensure we have up to date karma count
|
||||
comment = comments.get_object(pk=comment_id)
|
||||
return render_to_response('comments/karma_vote_accepted', {'comment': comment}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, context_instance=RequestContext(request))
|
||||
|
@ -22,7 +22,7 @@ def flag(request, comment_id):
|
||||
if request.POST:
|
||||
userflags.flag(comment, request.user)
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('comments/flag_verify', {'comment': comment}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/flag_verify.html', {'comment': comment}, context_instance=RequestContext(request))
|
||||
flag = login_required(flag)
|
||||
|
||||
def flag_done(request, comment_id):
|
||||
@ -30,7 +30,7 @@ def flag_done(request, comment_id):
|
||||
comment = comments.get_object(pk=comment_id, site__id__exact=settings.SITE_ID)
|
||||
except comments.CommentDoesNotExist:
|
||||
raise Http404
|
||||
return render_to_response('comments/flag_done', {'comment': comment}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/flag_done.html', {'comment': comment}, context_instance=RequestContext(request))
|
||||
|
||||
def delete(request, comment_id):
|
||||
"""
|
||||
@ -55,7 +55,7 @@ def delete(request, comment_id):
|
||||
m = moderatordeletions.ModeratorDeletion(None, request.user.id, comment.id, None)
|
||||
m.save()
|
||||
return HttpResponseRedirect('%sdone/' % request.path)
|
||||
return render_to_response('comments/delete_verify', {'comment': comment}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/delete_verify.html', {'comment': comment}, context_instance=RequestContext(request))
|
||||
delete = login_required(delete)
|
||||
|
||||
def delete_done(request, comment_id):
|
||||
@ -63,4 +63,4 @@ def delete_done(request, comment_id):
|
||||
comment = comments.get_object(pk=comment_id, site__id__exact=settings.SITE_ID)
|
||||
except comments.CommentDoesNotExist:
|
||||
raise Http404
|
||||
return render_to_response('comments/delete_done', {'comment': comment}, context_instance=RequestContext(request))
|
||||
return render_to_response('comments/delete_done.html', {'comment': comment}, context_instance=RequestContext(request))
|
||||
|
@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
from django.conf import settings
|
||||
|
||||
DEFAULT_TEMPLATE = 'flatpages/default'
|
||||
DEFAULT_TEMPLATE = 'flatpages/default.html'
|
||||
|
||||
def flatpage(request, url):
|
||||
"""
|
||||
@ -12,7 +12,7 @@ def flatpage(request, url):
|
||||
|
||||
Models: `flatpages.flatpages`
|
||||
Templates: Uses the template defined by the ``template_name`` field,
|
||||
or `flatpages/default` if template_name is not defined.
|
||||
or `flatpages/default.html` if template_name is not defined.
|
||||
Context:
|
||||
flatpage
|
||||
`flatpages.flatpages` object
|
||||
|
@ -76,11 +76,11 @@ class Feed:
|
||||
)
|
||||
|
||||
try:
|
||||
title_template = loader.get_template('feeds/%s_title' % self.slug)
|
||||
title_template = loader.get_template('feeds/%s_title.html' % self.slug)
|
||||
except TemplateDoesNotExist:
|
||||
title_template = Template('{{ obj }}')
|
||||
try:
|
||||
description_template = loader.get_template('feeds/%s_description' % self.slug)
|
||||
description_template = loader.get_template('feeds/%s_description.html' % self.slug)
|
||||
except TemplateDoesNotExist:
|
||||
description_template = Template('{{ obj }}')
|
||||
|
||||
|
@ -29,7 +29,7 @@ app_template_dirs = tuple(app_template_dirs)
|
||||
|
||||
def get_template_sources(template_name, template_dirs=None):
|
||||
for template_dir in app_template_dirs:
|
||||
yield os.path.join(template_dir, template_name) + settings.TEMPLATE_FILE_EXTENSION
|
||||
yield os.path.join(template_dir, template_name)
|
||||
|
||||
def load_template_source(template_name, template_dirs=None):
|
||||
for filepath in get_template_sources(template_name, template_dirs):
|
||||
|
@ -15,7 +15,7 @@ def load_template_source(template_name, template_dirs=None):
|
||||
For every installed app, it tries to get the resource (app, template_name).
|
||||
"""
|
||||
if resource_string is not None:
|
||||
pkg_name = 'templates/' + template_name + settings.TEMPLATE_FILE_EXTENSION
|
||||
pkg_name = 'templates/' + template_name
|
||||
for app in settings.INSTALLED_APPS:
|
||||
try:
|
||||
return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name))
|
||||
|
@ -8,7 +8,7 @@ def get_template_sources(template_name, template_dirs=None):
|
||||
if not template_dirs:
|
||||
template_dirs = settings.TEMPLATE_DIRS
|
||||
for template_dir in template_dirs:
|
||||
yield os.path.join(template_dir, template_name) + settings.TEMPLATE_FILE_EXTENSION
|
||||
yield os.path.join(template_dir, template_name)
|
||||
|
||||
def load_template_source(template_name, template_dirs=None):
|
||||
tried = []
|
||||
|
@ -261,7 +261,7 @@ The simple, raw way to limit access to pages is to check
|
||||
|
||||
def my_view(request):
|
||||
if request.user.is_anonymous():
|
||||
return render_to_response('myapp/login_error')
|
||||
return render_to_response('myapp/login_error.html')
|
||||
# ...
|
||||
|
||||
The login_required decorator
|
||||
@ -548,7 +548,7 @@ a playlist::
|
||||
# Create the playlist with the given songs.
|
||||
# ...
|
||||
request.user.message_set.create(message="Your playlist was added successfully.")
|
||||
return render_to_response("playlists/create", context_instance=RequestContext(request))
|
||||
return render_to_response("playlists/create.html", context_instance=RequestContext(request))
|
||||
|
||||
When you use ``RequestContext``, the currently logged-in user and his/her
|
||||
messages are made available in the `template context`_ as the template variable
|
||||
|
@ -651,14 +651,6 @@ these paths should use Unix-style forward slashes, even on Windows.
|
||||
|
||||
See the `template documentation`_.
|
||||
|
||||
TEMPLATE_FILE_EXTENSION
|
||||
-----------------------
|
||||
|
||||
Default: ``'.html'``
|
||||
|
||||
The file extension to append to all template names when searching for
|
||||
templates. See the `template documentation`_.
|
||||
|
||||
TEMPLATE_LOADERS
|
||||
----------------
|
||||
|
||||
|
@ -120,10 +120,11 @@ One thing's left to do. In an RSS feed, each ``<item>`` has a ``<title>``,
|
||||
put into those elements.
|
||||
|
||||
* To specify the contents of ``<title>`` and ``<description>``, create
|
||||
`Django templates`_ called ``feeds/sitenews_title`` and
|
||||
``feeds/sitenews_description``, where ``sitenews`` is the ``slug``
|
||||
specified in the URLconf for the given feed. The RSS system renders that
|
||||
template for each item, passing it two template context variables:
|
||||
`Django templates`_ called ``feeds/sitenews_title.html`` and
|
||||
``feeds/sitenews_description.html``, where ``sitenews`` is the ``slug``
|
||||
specified in the URLconf for the given feed. Note the ``.html`` extension
|
||||
is required. The RSS system renders that template for each item, passing
|
||||
it two template context variables:
|
||||
|
||||
* ``{{ obj }}`` -- The current object (one of whichever objects you
|
||||
returned in ``items()``).
|
||||
|
@ -533,9 +533,9 @@ Loads a template and renders it with the current context. This is a way of
|
||||
The template name can either be a variable or a hard-coded (quoted) string,
|
||||
in either single or double quotes.
|
||||
|
||||
This example includes the contents of the template ``"foo/bar"``::
|
||||
This example includes the contents of the template ``"foo/bar.html"``::
|
||||
|
||||
{% include "foo/bar" %}
|
||||
{% include "foo/bar.html" %}
|
||||
|
||||
This example includes the contents of the template whose name is contained in
|
||||
the variable ``template_name``::
|
||||
@ -548,9 +548,9 @@ including it. This example produces the output ``"Hello, John"``:
|
||||
* Context: variable ``person`` is set to ``"john"``.
|
||||
* Template::
|
||||
|
||||
{% include "name_snippet" %}
|
||||
{% include "name_snippet.html" %}
|
||||
|
||||
* The ``name_snippet`` template::
|
||||
* The ``name_snippet.html`` template::
|
||||
|
||||
Hello, {{ person }}
|
||||
|
||||
|
@ -363,15 +363,8 @@ Loading templates
|
||||
-----------------
|
||||
|
||||
Generally, you'll store templates in files on your filesystem rather than using
|
||||
the low-level ``Template`` API yourself. Save templates in a file with an
|
||||
".html" extension in a directory specified as a **template directory**.
|
||||
|
||||
If you don't like the requirement that templates have an ".html" extension,
|
||||
change your ``TEMPLATE_FILE_EXTENSION`` setting. It's set to ``".html"`` by
|
||||
default.
|
||||
|
||||
Also, the .html extension doesn't mean templates can contain only HTML. They
|
||||
can contain whatever textual content you want.
|
||||
the low-level ``Template`` API yourself. Save templates in a directory
|
||||
specified as a **template directory**.
|
||||
|
||||
The TEMPLATE_DIRS setting
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -386,7 +379,8 @@ that contain full paths to your template directory(ies). Example::
|
||||
)
|
||||
|
||||
Your templates can go anywhere you want, as long as the directories and
|
||||
templates are readable by the Web server.
|
||||
templates are readable by the Web server. They can have any extension you want,
|
||||
such as ``.html`` or ``.txt`` or whatever.
|
||||
|
||||
Note that these paths should use Unix-style forward slashes, even on Windows.
|
||||
|
||||
@ -404,14 +398,15 @@ Django has two ways to load templates from files:
|
||||
``select_template`` is just like ``get_template``, except it takes a list
|
||||
of template names. Of the list, it returns the first template that exists.
|
||||
|
||||
For example, if you call ``get_template("story_detail")`` and have the above
|
||||
``TEMPLATE_DIRS`` setting, here are the files Django will look for, in order:
|
||||
For example, if you call ``get_template("story_detail.html")`` and have the
|
||||
above ``TEMPLATE_DIRS`` setting, here are the files Django will look for, in
|
||||
order:
|
||||
|
||||
* ``/home/html/templates/lawrence.com/story_detail.html``
|
||||
* ``/home/html/templates/default/story_detail.html``
|
||||
|
||||
If you call ``select_template(["story_253_detail", "story_detail"])``, here's
|
||||
what Django will look for:
|
||||
If you call ``select_template(["story_253_detail.html", "story_detail.html"])``,
|
||||
here's what Django will look for:
|
||||
|
||||
* ``/home/html/templates/lawrence.com/story_253_detail.html``
|
||||
* ``/home/html/templates/default/story_253_detail.html``
|
||||
@ -425,7 +420,7 @@ When Django finds a template that exists, it stops looking.
|
||||
You can use ``select_template`` for super-flexible "templatability." For
|
||||
example, if you've written a news story and want some stories to have
|
||||
custom templates, use something like
|
||||
``select_template(["story_%s_detail" % story.id, "story_detail"])``.
|
||||
``select_template(["story_%s_detail.html" % story.id, "story_detail.html"])``.
|
||||
That'll allow you to use a custom template for an individual story, with a
|
||||
fallback template for stories that don't have custom templates.
|
||||
|
||||
@ -441,7 +436,7 @@ single directory gets messy.
|
||||
|
||||
To load a template that's within a subdirectory, just use a slash, like so::
|
||||
|
||||
get_template("news/story_detail")
|
||||
get_template("news/story_detail.html")
|
||||
|
||||
Loader types
|
||||
~~~~~~~~~~~~
|
||||
@ -467,7 +462,7 @@ a template loader. Here are the built-in template loaders:
|
||||
|
||||
INSTALLED_APPS = ('myproject.polls', 'myproject.music')
|
||||
|
||||
...then ``get_template("foo")`` will look for templates in these
|
||||
...then ``get_template("foo.html")`` will look for templates in these
|
||||
directories, in this order:
|
||||
|
||||
* ``/path/to/myproject/polls/templates/foo.html``
|
||||
|
@ -203,7 +203,7 @@ So let's use Django's template system to separate the design from Python::
|
||||
|
||||
def index(request):
|
||||
latest_poll_list = Poll.objects.all().order_by('-pub_date')
|
||||
t = loader.get_template('polls/index')
|
||||
t = loader.get_template('polls/index.html')
|
||||
c = Context({
|
||||
'latest_poll_list': latest_poll_list,
|
||||
})
|
||||
@ -227,9 +227,8 @@ find templates -- just as you did in the "Customize the admin look and feel"
|
||||
section of Tutorial 2.
|
||||
|
||||
When you've done that, create a directory ``polls`` in your template directory.
|
||||
Within that, create a file called ``index.html``. Django requires that
|
||||
templates have ".html" extension. Note that our
|
||||
``loader.get_template('polls/index')`` code from above maps to
|
||||
Within that, create a file called ``index.html``. Note that our
|
||||
``loader.get_template('polls/index.html')`` code from above maps to
|
||||
"[template_directory]/polls/index.html" on the filesystem.
|
||||
|
||||
Put the following code in that template::
|
||||
|
Loading…
x
Reference in New Issue
Block a user