From d3205e3e2eb0202e7bdffaee3e2a80ad444b1ca2 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Wed, 17 Dec 2014 22:51:42 +0100 Subject: Deprecated TEMPLATE_DIRS. --- docs/intro/tutorial02.txt | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'docs/intro/tutorial02.txt') diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index ae32a448e9..8039994f40 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -488,15 +488,32 @@ whatever user your server runs.) However, keeping your templates within the project is a good convention to follow. Open your settings file (:file:`mysite/settings.py`, remember) and add a -:setting:`TEMPLATE_DIRS` setting: +:setting:`DIRS ` option in the :setting:`TEMPLATES` setting: .. snippet:: :filename: mysite/settings.py - TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] - -:setting:`TEMPLATE_DIRS` is an iterable of filesystem directories to check when -loading Django templates; it's a search path. + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.tz', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, + ] + +:setting:`DIRS ` is a list of filesystem directories to check +when loading Django templates; it's a search path. Now create a directory called ``admin`` inside ``templates``, and copy the template ``admin/base_site.html`` from within the default Django admin @@ -547,10 +564,11 @@ changes. Customizing your *application's* templates ------------------------------------------ -Astute readers will ask: But if :setting:`TEMPLATE_DIRS` was empty by default, -how was Django finding the default admin templates? The answer is that, by -default, Django automatically looks for a ``templates/`` subdirectory within -each application package, for use as a fallback (don't forget that +Astute readers will ask: But if :setting:`DIRS ` was empty by +default, how was Django finding the default admin templates? The answer is +that, since :setting:`APP_DIRS ` is set to ``True``, +Django automatically looks for a ``templates/`` subdirectory within each +application package, for use as a fallback (don't forget that ``django.contrib.admin`` is an application). Our poll application is not very complex and doesn't need custom admin -- cgit v1.3