Removed deprecated TEMPLATE_* settings per deprecation timeline.

This commit is contained in:
Tim Graham 2015-09-05 08:34:19 -04:00
parent 9023696613
commit 2a20ebe6a5
6 changed files with 6 additions and 176 deletions

View File

@ -10,7 +10,6 @@ gettext_noop = lambda s: s
#################### ####################
DEBUG = False DEBUG = False
TEMPLATE_DEBUG = False
# Whether the framework should propagate raw exceptions rather than catching # Whether the framework should propagate raw exceptions rather than catching
# them. This is useful under some testing situations and should never be used # them. This is useful under some testing situations and should never be used
@ -199,34 +198,6 @@ EMAIL_TIMEOUT = None
# List of strings representing installed apps. # List of strings representing installed apps.
INSTALLED_APPS = [] INSTALLED_APPS = []
# List of locations of the template source files, in search order.
TEMPLATE_DIRS = []
# List of callables that know how to import templates from various sources.
# See the comments in django/core/template/loader.py for interface
# documentation.
TEMPLATE_LOADERS = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
# List of processors used by RequestContext to populate the context.
# Each one should be a callable that takes the request object as its
# only parameter and returns a dictionary to add to the context.
TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
# 'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
]
# Output to use in template system for invalid (e.g. misspelled) variables.
TEMPLATE_STRING_IF_INVALID = ''
TEMPLATES = [] TEMPLATES = []
# Default email address to use for various automated correspondence from # Default email address to use for various automated correspondence from

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import global_settings, settings from django.conf import settings
from .. import Tags, Warning, register from .. import Tags, Warning, register
@ -15,16 +15,13 @@ def check_duplicate_template_settings(app_configs, **kwargs):
'TEMPLATE_LOADERS', 'TEMPLATE_LOADERS',
'TEMPLATE_STRING_IF_INVALID', 'TEMPLATE_STRING_IF_INVALID',
] ]
duplicates = [ defined = [value for value in values if getattr(settings, value, None)]
value for value in values if defined:
if getattr(settings, value) != getattr(global_settings, value)
]
if duplicates:
return [Warning( return [Warning(
"The standalone TEMPLATE_* settings were deprecated in Django " "The standalone TEMPLATE_* settings were deprecated in Django "
"1.8 and the TEMPLATES dictionary takes precedence. You must " "1.8 and the TEMPLATES dictionary takes precedence. You must "
"put the values of the following settings into your default " "put the values of the following settings into your default "
"TEMPLATES dict: %s." % ", ".join(duplicates), "TEMPLATES dict: %s." % ", ".join(defined),
id='1_8.W001', id='1_8.W001',
)] )]
return [] return []

View File

@ -1,5 +1,4 @@
import os import os
import warnings
from collections import Counter, OrderedDict from collections import Counter, OrderedDict
from django.apps import apps from django.apps import apps
@ -7,7 +6,6 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.utils import lru_cache from django.utils import lru_cache
from django.utils._os import upath from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango110Warning
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
@ -30,24 +28,6 @@ class EngineHandler(object):
if self._templates is None: if self._templates is None:
self._templates = settings.TEMPLATES self._templates = settings.TEMPLATES
if not self._templates:
warnings.warn(
"You haven't defined a TEMPLATES setting. You must do so "
"before upgrading to Django 1.10. Otherwise Django will be "
"unable to load templates.", RemovedInDjango110Warning)
self._templates = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': settings.TEMPLATE_DIRS,
'OPTIONS': {
'context_processors': settings.TEMPLATE_CONTEXT_PROCESSORS,
'debug': settings.TEMPLATE_DEBUG,
'loaders': settings.TEMPLATE_LOADERS,
'string_if_invalid': settings.TEMPLATE_STRING_IF_INVALID,
},
},
]
templates = OrderedDict() templates = OrderedDict()
backend_names = [] backend_names = []
for tpl in self._templates: for tpl in self._templates:

View File

@ -84,11 +84,6 @@ def clear_routers_cache(**kwargs):
def reset_template_engines(**kwargs): def reset_template_engines(**kwargs):
if kwargs['setting'] in { if kwargs['setting'] in {
'TEMPLATES', 'TEMPLATES',
'TEMPLATE_DIRS',
'TEMPLATE_CONTEXT_PROCESSORS',
'TEMPLATE_DEBUG',
'TEMPLATE_LOADERS',
'TEMPLATE_STRING_IF_INVALID',
'DEBUG', 'DEBUG',
'FILE_CHARSET', 'FILE_CHARSET',
'INSTALLED_APPS', 'INSTALLED_APPS',

View File

@ -252,9 +252,8 @@ that might occur as a result of a version upgrade.
* **1_8.W001**: The standalone ``TEMPLATE_*`` settings were deprecated in * **1_8.W001**: The standalone ``TEMPLATE_*`` settings were deprecated in
Django 1.8 and the :setting:`TEMPLATES` dictionary takes precedence. You must Django 1.8 and the :setting:`TEMPLATES` dictionary takes precedence. You must
put the values of the following settings into your defaults ``TEMPLATES`` put the values of the following settings into your defaults ``TEMPLATES``
dict: :setting:`TEMPLATE_DIRS`, :setting:`TEMPLATE_CONTEXT_PROCESSORS`, dict: ``TEMPLATE_DIRS``, ``TEMPLATE_CONTEXT_PROCESSORS``, ``TEMPLATE_DEBUG``,
:setting:`TEMPLATE_DEBUG`, :setting:`TEMPLATE_LOADERS`, ``TEMPLATE_LOADERS``, ``TEMPLATE_STRING_IF_INVALID``.
:setting:`TEMPLATE_STRING_IF_INVALID`.
Admin Admin
----- -----

View File

@ -2314,113 +2314,6 @@ depending on the template backend. See
:class:`~django.template.backends.jinja2.Jinja2` for the options of the :class:`~django.template.backends.jinja2.Jinja2` for the options of the
built-in backends. built-in backends.
.. setting:: TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS
---------------------------
Default::
["django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages"]
.. deprecated:: 1.8
Set the ``'context_processors'`` option in the :setting:`OPTIONS
<TEMPLATES-OPTIONS>` of a ``DjangoTemplates`` backend instead.
A list of callables that are used to populate the context in ``RequestContext``.
These callables take a request object as their argument and return a dictionary
of items to be merged into the context.
.. versionchanged:: 1.8
Built-in template context processors were moved from
``django.core.context_processors`` to
``django.template.context_processors`` in Django 1.8.
.. setting:: TEMPLATE_DEBUG
TEMPLATE_DEBUG
--------------
Default: ``False``
.. deprecated:: 1.8
Set the ``'debug'`` option in the :setting:`OPTIONS <TEMPLATES-OPTIONS>`
of a ``DjangoTemplates`` backend instead.
A boolean that turns on/off template debug mode. If this is ``True``, the fancy
error page will display a detailed report for any exception raised during
template rendering. This report contains the relevant snippet of the template,
with the appropriate line highlighted.
Note that Django only displays fancy error pages if :setting:`DEBUG` is ``True``, so
you'll want to set that to take advantage of this setting.
See also :setting:`DEBUG`.
.. setting:: TEMPLATE_DIRS
TEMPLATE_DIRS
-------------
Default: ``[]`` (Empty list)
.. deprecated:: 1.8
Set the :setting:`DIRS <TEMPLATES-DIRS>` option of a ``DjangoTemplates``
backend instead.
List of locations of the template source files searched by
:class:`django.template.loaders.filesystem.Loader`, in search order.
Note that these paths should use Unix-style forward slashes, even on Windows.
See :doc:`/ref/templates/language`.
.. setting:: TEMPLATE_LOADERS
TEMPLATE_LOADERS
----------------
Default::
['django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader']
.. deprecated:: 1.8
Set the ``'loaders'`` option in the :setting:`OPTIONS <TEMPLATES-OPTIONS>`
of a ``DjangoTemplates`` backend instead.
A list of template loader classes, specified as strings. Each ``Loader`` class
knows how to import templates from a particular source. Optionally, a tuple can be
used instead of a string. The first item in the tuple should be the ``Loader``s
module, subsequent items are passed to the ``Loader`` during initialization. See
:doc:`/ref/templates/api`.
.. setting:: TEMPLATE_STRING_IF_INVALID
TEMPLATE_STRING_IF_INVALID
--------------------------
Default: ``''`` (Empty string)
.. deprecated:: 1.8
Set the ``'string_if_invalid'`` option in the :setting:`OPTIONS
<TEMPLATES-OPTIONS>` of a ``DjangoTemplates`` backend instead.
Output, as a string, that the template system should use for invalid (e.g.
misspelled) variables. See :ref:`invalid-template-variables`.
.. setting:: TEST_RUNNER .. setting:: TEST_RUNNER
TEST_RUNNER TEST_RUNNER
@ -3406,11 +3299,6 @@ Serialization
Templates Templates
--------- ---------
* :setting:`TEMPLATES` * :setting:`TEMPLATES`
* :setting:`TEMPLATE_CONTEXT_PROCESSORS`
* :setting:`TEMPLATE_DEBUG`
* :setting:`TEMPLATE_DIRS`
* :setting:`TEMPLATE_LOADERS`
* :setting:`TEMPLATE_STRING_IF_INVALID`
Testing Testing
------- -------