1
0
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:
Adrian Holovaty 2006-04-15 16:46:54 +00:00
parent 39d42d4861
commit 6442fd27bc
50 changed files with 124 additions and 140 deletions

View File

@ -102,9 +102,6 @@ INSTALLED_APPS = ()
# List of locations of the template source files, in search order. # List of locations of the template source files, in search order.
TEMPLATE_DIRS = () TEMPLATE_DIRS = ()
# Extension on all templates.
TEMPLATE_FILE_EXTENSION = '.html'
# List of callables that know how to import templates from various sources. # List of callables that know how to import templates from various sources.
# See the comments in django/core/template/loader.py for interface # See the comments in django/core/template/loader.py for interface
# documentation. # documentation.

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block title %}{% trans 'Page not found' %}{% endblock %} {% block title %}{% trans 'Page not found' %}{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans "Home" %}</a> &rsaquo; {% trans "Server error" %}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans "Home" %}</a> &rsaquo; {% trans "Server error" %}</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base" %} {% extends "admin/base.html" %}
{% load i18n %} {% load i18n %}
{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %} {% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n admin_modify adminmedia %} {% load i18n admin_modify adminmedia %}
{% block extrahead %}{{ block.super }} {% block extrahead %}{{ block.super }}
<script type="text/javascript" src="../../../jsi18n/"></script> <script type="text/javascript" src="../../../jsi18n/"></script>

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load adminmedia admin_list i18n %} {% load adminmedia admin_list i18n %}
{% block stylesheet %}{% admin_media_prefix %}css/changelists.css{% endblock %} {% block stylesheet %}{% admin_media_prefix %}css/changelists.css{% endblock %}
{% block bodyclass %}change-list{% endblock %} {% block bodyclass %}change-list{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% 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 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 %} {% block breadcrumbs %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css{% endblock %} {% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/login.css{% endblock %} {% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/login.css{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% 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 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 %} {% block breadcrumbs %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% block content %} {% block content %}

View File

@ -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> &rsaquo; <a href="../">{% trans "Documentation" %}</a> &rsaquo; {% trans "Bookmarklets" %}</div>{% endblock %} {% block breadcrumbs %}{% load i18n %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> &rsaquo; <a href="../">{% trans "Documentation" %}</a> &rsaquo; {% trans "Bookmarklets" %}</div>{% endblock %}
{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %}
{% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %}
{% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
{% block extrahead %} {% block extrahead %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block coltype %}colSM{% endblock %} {% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Models</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Models</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; Templates &rsaquo; {{ name }}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; Templates &rsaquo; {{ name }}</div>{% endblock %}
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block coltype %}colSM{% endblock %} {% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; filters</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; filters</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block coltype %}colSM{% endblock %} {% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Tags</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Tags</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; <a href="../">Views</a> &rsaquo; {{ name }}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; <a href="../">Views</a> &rsaquo; {{ name }}</div>{% endblock %}
{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %} {% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block coltype %}colSM{% endblock %} {% block coltype %}colSM{% endblock %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Views</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Views</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a></div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a></div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block userlinks %}<a href="../doc/">{% trans 'Documentation' %}</a> / {% trans 'Change password' %} / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %} {% 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> &rsaquo; {% trans 'Password change' %}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}</div>{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "admin/base_site" %} {% extends "admin/base_site.html" %}
{% load i18n %} {% load i18n %}
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}</div>{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}</div>{% endblock %}

View File

@ -1 +1 @@
{% include "widget/foreign" %} {% include "widget/foreign.html" %}

View File

@ -1 +1 @@
{% include "widget/foreign" %} {% include "widget/foreign.html" %}

View File

@ -65,7 +65,7 @@ def pagination(cl):
'ALL_VAR': ALL_VAR, 'ALL_VAR': ALL_VAR,
'1': 1, '1': 1,
} }
pagination = register.inclusion_tag('admin/pagination')(pagination) pagination = register.inclusion_tag('admin/pagination.html')(pagination)
def result_headers(cl): def result_headers(cl):
lookup_opts = cl.lookup_opts lookup_opts = cl.lookup_opts
@ -185,7 +185,7 @@ def result_list(cl):
return {'cl': cl, return {'cl': cl,
'result_headers': list(result_headers(cl)), 'result_headers': list(result_headers(cl)),
'results': list(results(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): def date_hierarchy(cl):
if cl.lookup_opts.admin.date_hierarchy: if cl.lookup_opts.admin.date_hierarchy:
@ -245,7 +245,7 @@ def date_hierarchy(cl):
'title': year.year 'title': year.year
} for year in years] } 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): def search_form(cl):
return { 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, 'show_result_count': cl.result_count != cl.full_result_count and not cl.opts.one_to_one_field,
'search_var': SEARCH_VAR '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): def filter(cl, spec):
return {'title': spec.title(), 'choices' : list(spec.choices(cl))} 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): def filters(cl):
return {'cl': cl} return {'cl': cl}
filters = register.inclusion_tag('admin/filters')(filters) filters = register.inclusion_tag('admin/filters.html')(filters)

View File

@ -35,7 +35,7 @@ def submit_row(context):
'show_save_and_continue': not is_popup and context['has_change_permission'], 'show_save_and_continue': not is_popup and context['has_change_permission'],
'show_save': True '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): def field_label(bound_field):
class_names = [] class_names = []
@ -64,7 +64,7 @@ class FieldWidgetNode(template.Node):
if not cls.nodelists.has_key(klass): if not cls.nodelists.has_key(klass):
try: try:
field_class_name = klass.__name__ 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 nodelist = loader.get_template(template_name).nodelist
except template.TemplateDoesNotExist: except template.TemplateDoesNotExist:
super_klass = bool(klass.__bases__) and klass.__bases__[0] or None 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) nodelist = cls.get_nodelist(super_klass)
else: else:
if not cls.default: if not cls.default:
cls.default = loader.get_template("widget/default").nodelist cls.default = loader.get_template("widget/default.html").nodelist
nodelist = cls.default nodelist = cls.default
cls.nodelists[klass] = nodelist cls.nodelists[klass] = nodelist
@ -126,7 +126,7 @@ class TabularBoundRelatedObject(BoundRelatedObject):
self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url') self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url')
def template_name(self): def template_name(self):
return "admin/edit_inline_tabular" return "admin/edit_inline_tabular.html"
class StackedBoundRelatedObject(BoundRelatedObject): class StackedBoundRelatedObject(BoundRelatedObject):
def __init__(self, related_object, field_mapping, original): 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') self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url')
def template_name(self): def template_name(self):
return "admin/edit_inline_stacked" return "admin/edit_inline_stacked.html"
class EditInlineNode(template.Node): class EditInlineNode(template.Node):
def __init__(self, rel_var): def __init__(self, rel_var):
@ -229,4 +229,4 @@ def admin_field_line(context, argument_val):
'bound_fields': bound_fields, 'bound_fields': bound_fields,
'class_names': " ".join(class_names), '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)

View File

@ -19,7 +19,7 @@ def _display_login_form(request, error_message=''):
post_data = _encode_post_data(request.POST) post_data = _encode_post_data(request.POST)
else: else:
post_data = _encode_post_data({}) post_data = _encode_post_data({})
return render_to_response('admin/login', { return render_to_response('admin/login.html', {
'title': _('Log in'), 'title': _('Log in'),
'app_path': request.path, 'app_path': request.path,
'post_data': post_data, 'post_data': post_data,

View File

@ -17,13 +17,13 @@ MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
def doc_index(request): def doc_index(request):
if not utils.docutils_is_available: if not utils.docutils_is_available:
return missing_docutils_page(request) 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) doc_index = staff_member_required(doc_index)
def bookmarklets(request): def bookmarklets(request):
# Hack! This couples this view to the URL it lives at. # Hack! This couples this view to the URL it lives at.
admin_root = request.path[:-len('doc/bookmarklets/')] 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), 'admin_url': "%s://%s%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', get_host(request), admin_root),
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))
bookmarklets = staff_member_required(bookmarklets) bookmarklets = staff_member_required(bookmarklets)
@ -56,7 +56,7 @@ def template_tag_index(request):
'library': tag_library, '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) template_tag_index = staff_member_required(template_tag_index)
def template_filter_index(request): def template_filter_index(request):
@ -86,7 +86,7 @@ def template_filter_index(request):
'meta': metadata, 'meta': metadata,
'library': tag_library, '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) template_filter_index = staff_member_required(template_filter_index)
def view_index(request): def view_index(request):
@ -110,7 +110,7 @@ def view_index(request):
'site': Site.objects.get(pk=settings_mod.SITE_ID), 'site': Site.objects.get(pk=settings_mod.SITE_ID),
'url': simplify_regex(regex), '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) view_index = staff_member_required(view_index)
def view_detail(request, view): def view_detail(request, view):
@ -129,7 +129,7 @@ def view_detail(request, view):
body = utils.parse_rst(body, 'view', 'view:' + view) body = utils.parse_rst(body, 'view', 'view:' + view)
for key in metadata: for key in metadata:
metadata[key] = utils.parse_rst(metadata[key], 'model', 'view:' + view) 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, 'name': view,
'summary': title, 'summary': title,
'body': body, 'body': body,
@ -142,7 +142,7 @@ def model_index(request):
return missing_docutils_page(request) return missing_docutils_page(request)
m_list = [m._meta for m in models.get_models()] 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) model_index = staff_member_required(model_index)
def model_detail(request, app_label, model_name): 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), '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), 'name': '%s.%s' % (opts.app_label, opts.object_name),
'summary': "Fields on %s objects" % opts.object_name, 'summary': "Fields on %s objects" % opts.object_name,
'description': model.__doc__, 'description': model.__doc__,
@ -236,7 +236,7 @@ def template_detail(request, template):
'site': Site.objects.get(pk=settings_mod.SITE_ID), 'site': Site.objects.get(pk=settings_mod.SITE_ID),
'order': list(settings_mod.TEMPLATE_DIRS).index(dir), '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, 'name': template,
'templates': templates, 'templates': templates,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))
@ -248,7 +248,7 @@ template_detail = staff_member_required(template_detail)
def missing_docutils_page(request): def missing_docutils_page(request):
"""Display an error message for people without docutils""" """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(): def load_all_installed_template_libraries():
# Load/register all template tag libraries from installed apps. # Load/register all template tag libraries from installed apps.

View File

@ -218,12 +218,12 @@ def render_change_form(model, manipulator, context, add=False, change=False, for
} }
context.update(extra_context) context.update(extra_context)
return render_to_response([ return render_to_response([
"admin/%s/%s/change_form" % (app_label, opts.object_name.lower()), "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()),
"admin/%s/change_form" % app_label, "admin/%s/change_form.html" % app_label,
"admin/change_form"], context_instance=context) "admin/change_form.html"], context_instance=context)
def index(request): 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)) 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): 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, "perms_lacking": perms_needed,
"opts": model._meta, "opts": model._meta,
} }
return render_to_response(["admin/%s/%s/delete_confirmation" % (app_label, opts.object_name.lower() ), return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
"admin/%s/delete_confirmation" % app_label , "admin/%s/delete_confirmation.html" % app_label ,
"admin/delete_confirmation"], extra_context, context_instance=template.RequestContext(request)) "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
delete_stage = staff_member_required(never_cache(delete_stage)) delete_stage = staff_member_required(never_cache(delete_stage))
def history(request, app_label, model_name, object_id): 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), 'module_name': capfirst(model._meta.verbose_name_plural),
'object': obj, 'object': obj,
} }
return render_to_response(["admin/%s/%s/object_history" % (app_label, model._meta.object_name.lower()), return render_to_response(["admin/%s/%s/object_history.html" % (app_label, model._meta.object_name.lower()),
"admin/%s/object_history" % app_label , "admin/%s/object_history.html" % app_label ,
"admin/object_history"], extra_context, context_instance=template.RequestContext(request)) "admin/object_history.html"], extra_context, context_instance=template.RequestContext(request))
history = staff_member_required(never_cache(history)) history = staff_member_required(never_cache(history))
class ChangeList(object): class ChangeList(object):
@ -734,7 +734,7 @@ def change_list(request, app_label, model_name):
'cl': cl, 'cl': cl,
}) })
c.update({'has_add_permission': c['perms'][app_label][cl.opts.get_add_permission()]}), 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()), return render_to_response(['admin/%s/%s/change_list.html' % (app_label, cl.opts.object_name.lower()),
'admin/%s/change_list' % app_label, 'admin/%s/change_list.html' % app_label,
'admin/change_list'], context_instance=c) 'admin/change_list.html'], context_instance=c)
change_list = staff_member_required(never_cache(change_list)) change_list = staff_member_required(never_cache(change_list))

View File

@ -23,7 +23,7 @@ def template_validator(request):
errors = manipulator.get_validation_errors(new_data) errors = manipulator.get_validation_errors(new_data)
if not errors: if not errors:
request.user.add_message('The template is valid.') 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', 'title': 'Template validator',
'form': forms.FormWrapper(manipulator, new_data, errors), 'form': forms.FormWrapper(manipulator, new_data, errors),
}, context_instance=template.RequestContext(request)) }, context_instance=template.RequestContext(request))

View File

@ -75,7 +75,7 @@ class PasswordResetForm(forms.Manipulator):
domain = current_site.domain domain = current_site.domain
else: else:
site_name = domain = domain_override site_name = domain = domain_override
t = loader.get_template('registration/password_reset_email') t = loader.get_template('registration/password_reset_email.html')
c = { c = {
'new_password': new_pass, 'new_password': new_pass,
'email': self.user_cache.email, 'email': self.user_cache.email,

View File

@ -25,7 +25,7 @@ def login(request):
else: else:
errors = {} errors = {}
request.session.set_test_cookie() 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), 'form': forms.FormWrapper(manipulator, request.POST, errors),
REDIRECT_FIELD_NAME: redirect_to, REDIRECT_FIELD_NAME: redirect_to,
'site_name': Site.objects.get_current().name, 'site_name': Site.objects.get_current().name,
@ -36,7 +36,7 @@ def logout(request, next_page=None):
try: try:
del request.session[SESSION_KEY] del request.session[SESSION_KEY]
except KeyError: 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: else:
# Redirect to this page until the session has been cleared. # Redirect to this page until the session has been cleared.
return HttpResponseRedirect(next_page or request.path) return HttpResponseRedirect(next_page or request.path)
@ -61,11 +61,11 @@ def password_reset(request, is_admin_site=False):
else: else:
form.save() form.save()
return HttpResponseRedirect('%sdone/' % request.path) 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)) context_instance=RequestContext(request))
def password_reset_done(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): def password_change(request):
new_data, errors = {}, {} new_data, errors = {}, {}
@ -76,9 +76,9 @@ def password_change(request):
if not errors: if not errors:
form.save(new_data) form.save(new_data)
return HttpResponseRedirect('%sdone/' % request.path) 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)) context_instance=RequestContext(request))
password_change = login_required(password_change) password_change = login_required(password_change)
def password_change_done(request): 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))

View File

@ -232,7 +232,7 @@ def post_comment(request):
return field_list return field_list
comment = errors and '' or manipulator.get_comment(new_data) comment = errors and '' or manipulator.get_comment(new_data)
comment_form = CommentFormWrapper(manipulator, new_data, errors, rating_choices) 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': comment,
'comment_form': comment_form, 'comment_form': comment_form,
'options': options, 'options': options,
@ -300,7 +300,7 @@ def post_free_comment(request):
errors = manipulator.get_validation_errors(new_data) errors = manipulator.get_validation_errors(new_data)
if errors or request.POST.has_key('preview'): if errors or request.POST.has_key('preview'):
comment = errors and '' or manipulator.get_comment(new_data) 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': comment,
'comment_form': forms.FormWrapper(manipulator, new_data, errors), 'comment_form': forms.FormWrapper(manipulator, new_data, errors),
'options': options, 'options': options,
@ -337,4 +337,4 @@ def comment_was_posted(request):
obj = content_type.get_object_for_this_type(pk=object_id) obj = content_type.get_object_for_this_type(pk=object_id)
except ObjectDoesNotExist: except ObjectDoesNotExist:
pass 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))

View File

@ -26,4 +26,4 @@ def vote(request, comment_id, vote):
karma.vote(request.user.id, comment_id, rating) karma.vote(request.user.id, comment_id, rating)
# Reload comment to ensure we have up to date karma count # Reload comment to ensure we have up to date karma count
comment = comments.get_object(pk=comment_id) 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))

View File

@ -22,7 +22,7 @@ def flag(request, comment_id):
if request.POST: if request.POST:
userflags.flag(comment, request.user) userflags.flag(comment, request.user)
return HttpResponseRedirect('%sdone/' % request.path) 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) flag = login_required(flag)
def flag_done(request, comment_id): 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) comment = comments.get_object(pk=comment_id, site__id__exact=settings.SITE_ID)
except comments.CommentDoesNotExist: except comments.CommentDoesNotExist:
raise Http404 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): 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 = moderatordeletions.ModeratorDeletion(None, request.user.id, comment.id, None)
m.save() m.save()
return HttpResponseRedirect('%sdone/' % request.path) 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) delete = login_required(delete)
def delete_done(request, comment_id): 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) comment = comments.get_object(pk=comment_id, site__id__exact=settings.SITE_ID)
except comments.CommentDoesNotExist: except comments.CommentDoesNotExist:
raise Http404 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))

View File

@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404
from django.http import HttpResponse from django.http import HttpResponse
from django.conf import settings from django.conf import settings
DEFAULT_TEMPLATE = 'flatpages/default' DEFAULT_TEMPLATE = 'flatpages/default.html'
def flatpage(request, url): def flatpage(request, url):
""" """
@ -12,7 +12,7 @@ def flatpage(request, url):
Models: `flatpages.flatpages` Models: `flatpages.flatpages`
Templates: Uses the template defined by the ``template_name`` field, 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: Context:
flatpage flatpage
`flatpages.flatpages` object `flatpages.flatpages` object

View File

@ -76,11 +76,11 @@ class Feed:
) )
try: try:
title_template = loader.get_template('feeds/%s_title' % self.slug) title_template = loader.get_template('feeds/%s_title.html' % self.slug)
except TemplateDoesNotExist: except TemplateDoesNotExist:
title_template = Template('{{ obj }}') title_template = Template('{{ obj }}')
try: try:
description_template = loader.get_template('feeds/%s_description' % self.slug) description_template = loader.get_template('feeds/%s_description.html' % self.slug)
except TemplateDoesNotExist: except TemplateDoesNotExist:
description_template = Template('{{ obj }}') description_template = Template('{{ obj }}')

View File

@ -29,7 +29,7 @@ app_template_dirs = tuple(app_template_dirs)
def get_template_sources(template_name, template_dirs=None): def get_template_sources(template_name, template_dirs=None):
for template_dir in app_template_dirs: 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): def load_template_source(template_name, template_dirs=None):
for filepath in get_template_sources(template_name, template_dirs): for filepath in get_template_sources(template_name, template_dirs):

View File

@ -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). For every installed app, it tries to get the resource (app, template_name).
""" """
if resource_string is not None: 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: for app in settings.INSTALLED_APPS:
try: try:
return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name)) return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name))

View File

@ -8,7 +8,7 @@ def get_template_sources(template_name, template_dirs=None):
if not template_dirs: if not template_dirs:
template_dirs = settings.TEMPLATE_DIRS template_dirs = settings.TEMPLATE_DIRS
for template_dir in 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): def load_template_source(template_name, template_dirs=None):
tried = [] tried = []

View File

@ -261,7 +261,7 @@ The simple, raw way to limit access to pages is to check
def my_view(request): def my_view(request):
if request.user.is_anonymous(): if request.user.is_anonymous():
return render_to_response('myapp/login_error') return render_to_response('myapp/login_error.html')
# ... # ...
The login_required decorator The login_required decorator
@ -548,7 +548,7 @@ a playlist::
# Create the playlist with the given songs. # Create the playlist with the given songs.
# ... # ...
request.user.message_set.create(message="Your playlist was added successfully.") 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 When you use ``RequestContext``, the currently logged-in user and his/her
messages are made available in the `template context`_ as the template variable messages are made available in the `template context`_ as the template variable

View File

@ -651,14 +651,6 @@ these paths should use Unix-style forward slashes, even on Windows.
See the `template documentation`_. 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 TEMPLATE_LOADERS
---------------- ----------------

View File

@ -120,10 +120,11 @@ One thing's left to do. In an RSS feed, each ``<item>`` has a ``<title>``,
put into those elements. put into those elements.
* To specify the contents of ``<title>`` and ``<description>``, create * To specify the contents of ``<title>`` and ``<description>``, create
`Django templates`_ called ``feeds/sitenews_title`` and `Django templates`_ called ``feeds/sitenews_title.html`` and
``feeds/sitenews_description``, where ``sitenews`` is the ``slug`` ``feeds/sitenews_description.html``, where ``sitenews`` is the ``slug``
specified in the URLconf for the given feed. The RSS system renders that specified in the URLconf for the given feed. Note the ``.html`` extension
template for each item, passing it two template context variables: 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 * ``{{ obj }}`` -- The current object (one of whichever objects you
returned in ``items()``). returned in ``items()``).

View File

@ -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, The template name can either be a variable or a hard-coded (quoted) string,
in either single or double quotes. 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 This example includes the contents of the template whose name is contained in
the variable ``template_name``:: the variable ``template_name``::
@ -548,9 +548,9 @@ including it. This example produces the output ``"Hello, John"``:
* Context: variable ``person`` is set to ``"john"``. * Context: variable ``person`` is set to ``"john"``.
* Template:: * Template::
{% include "name_snippet" %} {% include "name_snippet.html" %}
* The ``name_snippet`` template:: * The ``name_snippet.html`` template::
Hello, {{ person }} Hello, {{ person }}

View File

@ -363,15 +363,8 @@ Loading templates
----------------- -----------------
Generally, you'll store templates in files on your filesystem rather than using 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 the low-level ``Template`` API yourself. Save templates in a directory
".html" extension in a directory specified as a **template 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 TEMPLATE_DIRS setting 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 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. 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 ``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. 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 For example, if you call ``get_template("story_detail.html")`` and have the
``TEMPLATE_DIRS`` setting, here are the files Django will look for, in order: 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/lawrence.com/story_detail.html``
* ``/home/html/templates/default/story_detail.html`` * ``/home/html/templates/default/story_detail.html``
If you call ``select_template(["story_253_detail", "story_detail"])``, here's If you call ``select_template(["story_253_detail.html", "story_detail.html"])``,
what Django will look for: here's what Django will look for:
* ``/home/html/templates/lawrence.com/story_253_detail.html`` * ``/home/html/templates/lawrence.com/story_253_detail.html``
* ``/home/html/templates/default/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 You can use ``select_template`` for super-flexible "templatability." For
example, if you've written a news story and want some stories to have example, if you've written a news story and want some stories to have
custom templates, use something like 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 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. 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:: 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 Loader types
~~~~~~~~~~~~ ~~~~~~~~~~~~
@ -467,7 +462,7 @@ a template loader. Here are the built-in template loaders:
INSTALLED_APPS = ('myproject.polls', 'myproject.music') 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: directories, in this order:
* ``/path/to/myproject/polls/templates/foo.html`` * ``/path/to/myproject/polls/templates/foo.html``

View File

@ -203,7 +203,7 @@ So let's use Django's template system to separate the design from Python::
def index(request): def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date') 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({ c = Context({
'latest_poll_list': latest_poll_list, '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. section of Tutorial 2.
When you've done that, create a directory ``polls`` in your template directory. When you've done that, create a directory ``polls`` in your template directory.
Within that, create a file called ``index.html``. Django requires that Within that, create a file called ``index.html``. Note that our
templates have ".html" extension. Note that our ``loader.get_template('polls/index.html')`` code from above maps to
``loader.get_template('polls/index')`` code from above maps to
"[template_directory]/polls/index.html" on the filesystem. "[template_directory]/polls/index.html" on the filesystem.
Put the following code in that template:: Put the following code in that template::