mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
This commit is contained in:
@@ -62,7 +62,7 @@ from .exceptions import TemplateDoesNotExist, TemplateSyntaxError # NOQA
|
||||
from .base import (Context, Node, NodeList, Origin, RequestContext, # NOQA
|
||||
Template, Variable)
|
||||
|
||||
# Deprecated in Django 1.8, will be removed in Django 2.0.
|
||||
# Deprecated in Django 1.8, will be removed in Django 1.10.
|
||||
from .base import resolve_variable # NOQA
|
||||
|
||||
# Library management
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.template.context import Context, RequestContext, make_context
|
||||
from django.template.engine import Engine, _dirs_undefined
|
||||
from django.template.library import InvalidTemplateLibrary
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
|
||||
from .base import BaseEngine
|
||||
|
||||
@@ -69,7 +69,7 @@ class Template(object):
|
||||
# >>> template.render(Context({'name': 'world'}))
|
||||
# In Django 1.7 get_template() returned a django.template.Template.
|
||||
# In Django 1.8 it returns a django.template.backends.django.Template.
|
||||
# In Django 2.0 the isinstance checks should be removed. If passing a
|
||||
# In Django 1.10 the isinstance checks should be removed. If passing a
|
||||
# Context or a RequestContext works by accident, it won't be an issue
|
||||
# per se, but it won't be officially supported either.
|
||||
if isinstance(context, RequestContext):
|
||||
@@ -81,12 +81,12 @@ class Template(object):
|
||||
"the two arguments refer to the same request.")
|
||||
warnings.warn(
|
||||
"render() must be called with a dict, not a RequestContext.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
|
||||
elif isinstance(context, Context):
|
||||
warnings.warn(
|
||||
"render() must be called with a dict, not a Context.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
|
||||
else:
|
||||
context = make_context(context, request)
|
||||
|
||||
@@ -60,7 +60,7 @@ from django.template.context import ( # NOQA: imported for backwards compatibil
|
||||
BaseContext, Context, ContextPopException, RequestContext,
|
||||
)
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.encoding import (
|
||||
force_str, force_text, python_2_unicode_compatible,
|
||||
)
|
||||
@@ -749,7 +749,7 @@ def resolve_variable(path, context):
|
||||
"""
|
||||
warnings.warn("resolve_variable() is deprecated. Use django.template."
|
||||
"Variable(path).resolve(context) instead",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
return Variable(path).resolve(context)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import warnings
|
||||
from contextlib import contextmanager
|
||||
from copy import copy
|
||||
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
|
||||
# Hard-coded processor for easier use of CSRF protection.
|
||||
_builtin_context_processors = ('django.template.context_processors.csrf',)
|
||||
@@ -136,7 +136,7 @@ class Context(BaseContext):
|
||||
warnings.warn(
|
||||
"The current_app argument of Context is deprecated. Use "
|
||||
"RequestContext and set the current_app attribute of its "
|
||||
"request instead.", RemovedInDjango20Warning, stacklevel=2)
|
||||
"request instead.", RemovedInDjango110Warning, stacklevel=2)
|
||||
self.autoescape = autoescape
|
||||
self._current_app = current_app
|
||||
self.use_l10n = use_l10n
|
||||
@@ -221,7 +221,7 @@ class RequestContext(Context):
|
||||
warnings.warn(
|
||||
"The current_app argument of RequestContext is deprecated. "
|
||||
"Set the current_app attribute of its request instead.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
self._current_app = current_app
|
||||
self.request = request
|
||||
self._processors = () if processors is None else tuple(processors)
|
||||
|
||||
@@ -11,7 +11,7 @@ from pprint import pformat
|
||||
from django.conf import settings
|
||||
from django.utils import formats, six
|
||||
from django.utils.dateformat import format, time_format
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.encoding import force_text, iri_to_uri
|
||||
from django.utils.html import (
|
||||
avoid_wrapping, conditional_escape, escape, escapejs, linebreaks,
|
||||
@@ -716,8 +716,8 @@ def unordered_list(value, autoescape=True):
|
||||
if converted:
|
||||
warnings.warn(
|
||||
"The old style syntax in `unordered_list` is deprecated and will "
|
||||
"be removed in Django 2.0. Use the the new format instead.",
|
||||
RemovedInDjango20Warning)
|
||||
"be removed in Django 1.10. Use the the new format instead.",
|
||||
RemovedInDjango110Warning)
|
||||
return mark_safe(list_formatter(value))
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from itertools import cycle as itertools_cycle, groupby
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils import six, timezone
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.encoding import force_text, smart_text
|
||||
from django.utils.html import format_html
|
||||
from django.utils.lorem_ipsum import paragraphs, words
|
||||
@@ -203,9 +203,9 @@ class ForNode(Node):
|
||||
if num_loopvars != len_item:
|
||||
warnings.warn(
|
||||
"Need {} values to unpack in for loop; got {}. "
|
||||
"This will raise an exception in Django 2.0."
|
||||
"This will raise an exception in Django 1.10."
|
||||
.format(num_loopvars, len_item),
|
||||
RemovedInDjango20Warning)
|
||||
RemovedInDjango110Warning)
|
||||
try:
|
||||
unpacked_vars = dict(zip(self.loopvars, item))
|
||||
except TypeError:
|
||||
@@ -480,7 +480,7 @@ class URLNode(Node):
|
||||
current_app = context.request.current_app
|
||||
except AttributeError:
|
||||
# Change the fallback value to None when the deprecation path for
|
||||
# Context.current_app completes in Django 2.0.
|
||||
# Context.current_app completes in Django 1.10.
|
||||
current_app = context.current_app
|
||||
|
||||
# Try to look up the URL twice: once given the view name, and again
|
||||
@@ -653,7 +653,7 @@ def cycle(parser, token):
|
||||
if ',' in args[1]:
|
||||
warnings.warn(
|
||||
"The old {% cycle %} syntax with comma-separated arguments is deprecated.",
|
||||
RemovedInDjango20Warning,
|
||||
RemovedInDjango110Warning,
|
||||
)
|
||||
# Backwards compatibility: {% cycle a,b %} or {% cycle a,b as foo %}
|
||||
# case.
|
||||
@@ -1103,7 +1103,7 @@ def ssi(parser, token):
|
||||
"""
|
||||
warnings.warn(
|
||||
"The {% ssi %} tag is deprecated. Use the {% include %} tag instead.",
|
||||
RemovedInDjango20Warning,
|
||||
RemovedInDjango110Warning,
|
||||
)
|
||||
|
||||
bits = token.split_contents()
|
||||
|
||||
@@ -2,7 +2,7 @@ import warnings
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils import lru_cache, six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
@@ -141,7 +141,7 @@ class Engine(object):
|
||||
warnings.warn(
|
||||
"%s inherits from django.template.loader.BaseLoader "
|
||||
"instead of django.template.loaders.base.Loader. " %
|
||||
loader, RemovedInDjango20Warning, stacklevel=2)
|
||||
loader, RemovedInDjango110Warning, stacklevel=2)
|
||||
|
||||
return loader_class(*args)
|
||||
else:
|
||||
@@ -160,7 +160,7 @@ class Engine(object):
|
||||
except TemplateDoesNotExist as e:
|
||||
tried.extend(e.tried)
|
||||
else:
|
||||
# RemovedInDjango21Warning: Use old api for non-recursive
|
||||
# RemovedInDjango20Warning: Use old api for non-recursive
|
||||
# loaders.
|
||||
try:
|
||||
return loader(name, dirs)
|
||||
@@ -185,7 +185,7 @@ class Engine(object):
|
||||
else:
|
||||
warnings.warn(
|
||||
"The dirs argument of get_template is deprecated.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
|
||||
template, origin = self.find_template(template_name, dirs)
|
||||
if not hasattr(template, 'render'):
|
||||
@@ -196,7 +196,7 @@ class Engine(object):
|
||||
# This method was originally a function defined in django.template.loader.
|
||||
# It was moved here in Django 1.8 when encapsulating the Django template
|
||||
# engine in this Engine class. It's still called by deprecated code but it
|
||||
# will be removed in Django 2.0. It's superseded by a new render_to_string
|
||||
# will be removed in Django 1.10. It's superseded by a new render_to_string
|
||||
# function in django.template.loader.
|
||||
|
||||
def render_to_string(self, template_name, context=None,
|
||||
@@ -208,7 +208,7 @@ class Engine(object):
|
||||
else:
|
||||
warnings.warn(
|
||||
"The context_instance argument of render_to_string is "
|
||||
"deprecated.", RemovedInDjango20Warning, stacklevel=2)
|
||||
"deprecated.", RemovedInDjango110Warning, stacklevel=2)
|
||||
if dirs is _dirs_undefined:
|
||||
# Do not set dirs to None here to avoid triggering the deprecation
|
||||
# warning in select_template or get_template.
|
||||
@@ -216,13 +216,13 @@ class Engine(object):
|
||||
else:
|
||||
warnings.warn(
|
||||
"The dirs argument of render_to_string is deprecated.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
if dictionary is _dictionary_undefined:
|
||||
dictionary = None
|
||||
else:
|
||||
warnings.warn(
|
||||
"The dictionary argument of render_to_string was renamed to "
|
||||
"context.", RemovedInDjango20Warning, stacklevel=2)
|
||||
"context.", RemovedInDjango110Warning, stacklevel=2)
|
||||
context = dictionary
|
||||
|
||||
if isinstance(template_name, (list, tuple)):
|
||||
@@ -254,7 +254,7 @@ class Engine(object):
|
||||
else:
|
||||
warnings.warn(
|
||||
"The dirs argument of select_template is deprecated.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
|
||||
if not template_name_list:
|
||||
raise TemplateDoesNotExist("No template names provided")
|
||||
|
||||
@@ -3,7 +3,7 @@ import warnings
|
||||
from importlib import import_module
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.inspect import getargspec
|
||||
from django.utils.itercompat import is_iterable
|
||||
|
||||
@@ -136,7 +136,7 @@ class Library(object):
|
||||
def assignment_tag(self, func=None, takes_context=None, name=None):
|
||||
warnings.warn(
|
||||
"assignment_tag() is deprecated. Use simple_tag() instead",
|
||||
RemovedInDjango21Warning,
|
||||
RemovedInDjango20Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.simple_tag(func, takes_context, name)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import warnings
|
||||
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
|
||||
from . import engines
|
||||
from .backends.django import DjangoTemplates
|
||||
@@ -22,7 +22,7 @@ def get_template(template_name, dirs=_dirs_undefined, using=None):
|
||||
for engine in engines:
|
||||
try:
|
||||
# This is required for deprecating the dirs argument. Simply
|
||||
# return engine.get_template(template_name) in Django 2.0.
|
||||
# return engine.get_template(template_name) in Django 1.10.
|
||||
if isinstance(engine, DjangoTemplates):
|
||||
return engine.get_template(template_name, dirs)
|
||||
elif dirs is not _dirs_undefined:
|
||||
@@ -52,7 +52,7 @@ def select_template(template_name_list, dirs=_dirs_undefined, using=None):
|
||||
for engine in engines:
|
||||
try:
|
||||
# This is required for deprecating the dirs argument. Simply
|
||||
# use engine.get_template(template_name) in Django 2.0.
|
||||
# use engine.get_template(template_name) in Django 1.10.
|
||||
if isinstance(engine, DjangoTemplates):
|
||||
return engine.get_template(template_name, dirs)
|
||||
elif dirs is not _dirs_undefined:
|
||||
@@ -98,7 +98,7 @@ def render_to_string(template_name, context=None,
|
||||
try:
|
||||
# This is required for deprecating properly arguments specific
|
||||
# to Django templates. Remove Engine.render_to_string() at the
|
||||
# same time as this code path in Django 2.0.
|
||||
# same time as this code path in Django 1.10.
|
||||
if isinstance(engine, DjangoTemplates):
|
||||
if request is not None:
|
||||
raise ValueError(
|
||||
@@ -146,5 +146,5 @@ class BaseLoader(base.Loader):
|
||||
warnings.warn(
|
||||
"django.template.loader.BaseLoader was superseded by "
|
||||
"django.template.loaders.base.Loader.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
super(BaseLoader, self).__init__(*args, **kwargs)
|
||||
|
||||
@@ -101,7 +101,7 @@ class ExtendsNode(Node):
|
||||
passed as the skip argument. This enables extends to work recursively
|
||||
without extending the same template twice.
|
||||
"""
|
||||
# RemovedInDjango21Warning: If any non-recursive loaders are installed
|
||||
# RemovedInDjango20Warning: If any non-recursive loaders are installed
|
||||
# do a direct template lookup. If the same template name appears twice,
|
||||
# raise an exception to avoid system recursion.
|
||||
for loader in context.template.engine.template_loaders:
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import warnings
|
||||
|
||||
from django.template import Origin, Template, TemplateDoesNotExist
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.inspect import func_supports_parameter
|
||||
|
||||
|
||||
class Loader(object):
|
||||
# Only used to raise a deprecation warning. Remove in Django 2.0.
|
||||
# Only used to raise a deprecation warning. Remove in Django 1.10.
|
||||
is_usable = False
|
||||
_accepts_engine_in_init = True
|
||||
|
||||
def __init__(self, engine):
|
||||
self.engine = engine
|
||||
|
||||
def __call__(self, template_name, template_dirs=None):
|
||||
# RemovedInDjango21Warning: Allow loaders to be called like functions.
|
||||
# RemovedInDjango20Warning: Allow loaders to be called like functions.
|
||||
return self.load_template(template_name, template_dirs)
|
||||
|
||||
def get_template(self, template_name, template_dirs=None, skip=None):
|
||||
@@ -26,7 +27,7 @@ class Loader(object):
|
||||
tried = []
|
||||
|
||||
args = [template_name]
|
||||
# RemovedInDjango21Warning: Add template_dirs for compatibility with
|
||||
# RemovedInDjango20Warning: Add template_dirs for compatibility with
|
||||
# old loaders
|
||||
if func_supports_parameter(self.get_template_sources, 'template_dirs'):
|
||||
args.append(template_dirs)
|
||||
@@ -51,7 +52,7 @@ class Loader(object):
|
||||
def load_template(self, template_name, template_dirs=None):
|
||||
warnings.warn(
|
||||
'The load_template() method is deprecated. Use get_template() '
|
||||
'instead.', RemovedInDjango21Warning,
|
||||
'instead.', RemovedInDjango20Warning,
|
||||
)
|
||||
source, display_name = self.load_template_source(
|
||||
template_name, template_dirs,
|
||||
@@ -83,7 +84,7 @@ class Loader(object):
|
||||
|
||||
def load_template_source(self, template_name, template_dirs=None):
|
||||
"""
|
||||
RemovedInDjango21Warning: Returns a tuple containing the source and
|
||||
RemovedInDjango20Warning: Returns a tuple containing the source and
|
||||
origin for the given template name.
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
@@ -100,7 +101,7 @@ class Loader(object):
|
||||
@property
|
||||
def supports_recursion(self):
|
||||
"""
|
||||
RemovedInDjango21Warning: This is an internal property used by the
|
||||
RemovedInDjango20Warning: This is an internal property used by the
|
||||
ExtendsNode during the deprecation of non-recursive loaders.
|
||||
"""
|
||||
return hasattr(self, 'get_contents')
|
||||
|
||||
@@ -7,7 +7,7 @@ import hashlib
|
||||
import warnings
|
||||
|
||||
from django.template import Origin, Template, TemplateDoesNotExist
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.inspect import func_supports_parameter
|
||||
|
||||
@@ -18,7 +18,7 @@ class Loader(BaseLoader):
|
||||
|
||||
def __init__(self, engine, loaders):
|
||||
self.template_cache = {}
|
||||
self.find_template_cache = {} # RemovedInDjango21Warning
|
||||
self.find_template_cache = {} # RemovedInDjango20Warning
|
||||
self.get_template_cache = {}
|
||||
self.loaders = engine.get_template_loaders(loaders)
|
||||
super(Loader, self).__init__(engine)
|
||||
@@ -49,7 +49,7 @@ class Loader(BaseLoader):
|
||||
def get_template_sources(self, template_name, template_dirs=None):
|
||||
for loader in self.loaders:
|
||||
args = [template_name]
|
||||
# RemovedInDjango21Warning: Add template_dirs for compatibility
|
||||
# RemovedInDjango20Warning: Add template_dirs for compatibility
|
||||
# with old loaders
|
||||
if func_supports_parameter(loader.get_template_sources, 'template_dirs'):
|
||||
args.append(template_dirs)
|
||||
@@ -87,14 +87,14 @@ class Loader(BaseLoader):
|
||||
@property
|
||||
def supports_recursion(self):
|
||||
"""
|
||||
RemovedInDjango21Warning: This is an internal property used by the
|
||||
RemovedInDjango20Warning: This is an internal property used by the
|
||||
ExtendsNode during the deprecation of non-recursive loaders.
|
||||
"""
|
||||
return all(hasattr(loader, 'get_contents') for loader in self.loaders)
|
||||
|
||||
def find_template(self, name, dirs=None):
|
||||
"""
|
||||
RemovedInDjango21Warning: An internal method to lookup the template
|
||||
RemovedInDjango20Warning: An internal method to lookup the template
|
||||
name in all the configured loaders.
|
||||
"""
|
||||
key = self.cache_key(name, dirs)
|
||||
@@ -125,7 +125,7 @@ class Loader(BaseLoader):
|
||||
def load_template(self, template_name, template_dirs=None):
|
||||
warnings.warn(
|
||||
'The load_template() method is deprecated. Use get_template() '
|
||||
'instead.', RemovedInDjango21Warning,
|
||||
'instead.', RemovedInDjango20Warning,
|
||||
)
|
||||
key = self.cache_key(template_name, template_dirs)
|
||||
template_tuple = self.template_cache.get(key)
|
||||
@@ -149,5 +149,5 @@ class Loader(BaseLoader):
|
||||
def reset(self):
|
||||
"Empty the template cache."
|
||||
self.template_cache.clear()
|
||||
self.find_template_cache.clear() # RemovedInDjango21Warning
|
||||
self.find_template_cache.clear() # RemovedInDjango20Warning
|
||||
self.get_template_cache.clear()
|
||||
|
||||
@@ -6,7 +6,7 @@ import warnings
|
||||
from django.apps import apps
|
||||
from django.template import Origin, TemplateDoesNotExist
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
from .base import Loader as BaseLoader
|
||||
|
||||
@@ -62,7 +62,7 @@ class Loader(BaseLoader):
|
||||
warnings.warn(
|
||||
'The load_template_sources() method is deprecated. Use '
|
||||
'get_template() or get_contents() instead.',
|
||||
RemovedInDjango21Warning,
|
||||
RemovedInDjango20Warning,
|
||||
)
|
||||
for origin in self.get_template_sources(template_name):
|
||||
try:
|
||||
|
||||
@@ -9,7 +9,7 @@ import warnings
|
||||
from django.core.exceptions import SuspiciousFileOperation
|
||||
from django.template import Origin, TemplateDoesNotExist
|
||||
from django.utils._os import safe_join
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
from .base import Loader as BaseLoader
|
||||
|
||||
@@ -54,7 +54,7 @@ class Loader(BaseLoader):
|
||||
warnings.warn(
|
||||
'The load_template_sources() method is deprecated. Use '
|
||||
'get_template() or get_contents() instead.',
|
||||
RemovedInDjango21Warning,
|
||||
RemovedInDjango20Warning,
|
||||
)
|
||||
for origin in self.get_template_sources(template_name, template_dirs):
|
||||
try:
|
||||
|
||||
@@ -5,7 +5,7 @@ Wrapper for loading templates from a plain Python dict.
|
||||
import warnings
|
||||
|
||||
from django.template import Origin, TemplateDoesNotExist
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
|
||||
from .base import Loader as BaseLoader
|
||||
|
||||
@@ -33,7 +33,7 @@ class Loader(BaseLoader):
|
||||
warnings.warn(
|
||||
'The load_template_sources() method is deprecated. Use '
|
||||
'get_template() or get_contents() instead.',
|
||||
RemovedInDjango21Warning,
|
||||
RemovedInDjango20Warning,
|
||||
)
|
||||
try:
|
||||
return self.templates_dict[template_name], template_name
|
||||
|
||||
@@ -2,7 +2,7 @@ import warnings
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
|
||||
from .backends.django import Template as BackendTemplate
|
||||
from .base import Template
|
||||
@@ -24,7 +24,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
"{}'s template argument cannot be a django.template.Template "
|
||||
"anymore. It may be a backend-specific template like those "
|
||||
"created by get_template().".format(self.__class__.__name__),
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
template = BackendTemplate(template)
|
||||
|
||||
# It would seem obvious to call these next two members 'template' and
|
||||
@@ -86,7 +86,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
def _resolve_template(self, template):
|
||||
# This wrapper deprecates returning a django.template.Template in
|
||||
# subclasses that override resolve_template. It can be removed in
|
||||
# Django 2.0.
|
||||
# Django 1.10.
|
||||
new_template = self.resolve_template(template)
|
||||
if isinstance(new_template, Template):
|
||||
warnings.warn(
|
||||
@@ -94,7 +94,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
"template like those created by get_template(), not a "
|
||||
"{}.".format(
|
||||
self.__class__.__name__, new_template.__class__.__name__),
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
new_template = BackendTemplate(new_template)
|
||||
return new_template
|
||||
|
||||
@@ -104,7 +104,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
def _resolve_context(self, context):
|
||||
# This wrapper deprecates returning a Context or a RequestContext in
|
||||
# subclasses that override resolve_context. It can be removed in
|
||||
# Django 2.0. If returning a Context or a RequestContext works by
|
||||
# Django 1.10. If returning a Context or a RequestContext works by
|
||||
# accident, it won't be an issue per se, but it won't be officially
|
||||
# supported either.
|
||||
new_context = self.resolve_context(context)
|
||||
@@ -114,7 +114,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
warnings.warn(
|
||||
"{}.resolve_context() must return a dict, not a {}.".format(
|
||||
self.__class__.__name__, new_context.__class__.__name__),
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
# It would be tempting to do new_context = new_context.flatten()
|
||||
# here but that would cause template context processors to run for
|
||||
# TemplateResponse(request, template, Context({})), which would be
|
||||
@@ -201,7 +201,7 @@ class TemplateResponse(SimpleTemplateResponse):
|
||||
warnings.warn(
|
||||
"The current_app argument of TemplateResponse is deprecated. "
|
||||
"Set the current_app attribute of its request instead.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
RemovedInDjango110Warning, stacklevel=2)
|
||||
request.current_app = current_app
|
||||
super(TemplateResponse, self).__init__(
|
||||
template, context, content_type, status, charset, using)
|
||||
|
||||
@@ -3,7 +3,7 @@ Parser and utilities for the smart 'if' tag
|
||||
"""
|
||||
import warnings
|
||||
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
|
||||
|
||||
# Using a simple top down parser, as described here:
|
||||
@@ -102,7 +102,7 @@ OPERATORS = {
|
||||
'not': prefix(8, lambda context, x: not x.eval(context)),
|
||||
'in': infix(9, lambda context, x, y: x.eval(context) in y.eval(context)),
|
||||
'not in': infix(9, lambda context, x, y: x.eval(context) not in y.eval(context)),
|
||||
# This should be removed in Django 2.0:
|
||||
# This should be removed in Django 1.10:
|
||||
'=': infix(10, lambda context, x, y: x.eval(context) == y.eval(context)),
|
||||
'==': infix(10, lambda context, x, y: x.eval(context) == y.eval(context)),
|
||||
'!=': infix(10, lambda context, x, y: x.eval(context) != y.eval(context)),
|
||||
@@ -180,8 +180,8 @@ class IfParser(object):
|
||||
else:
|
||||
if token == '=':
|
||||
warnings.warn(
|
||||
"Operator '=' is deprecated and will be removed in Django 2.0. Use '==' instead.",
|
||||
RemovedInDjango20Warning, stacklevel=2
|
||||
"Operator '=' is deprecated and will be removed in Django 1.10. Use '==' instead.",
|
||||
RemovedInDjango110Warning, stacklevel=2
|
||||
)
|
||||
return op()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils import lru_cache
|
||||
from django.utils._os import upath
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.deprecation import RemovedInDjango110Warning
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
@@ -33,8 +33,8 @@ class EngineHandler(object):
|
||||
if not self._templates:
|
||||
warnings.warn(
|
||||
"You haven't defined a TEMPLATES setting. You must do so "
|
||||
"before upgrading to Django 2.0. Otherwise Django will be "
|
||||
"unable to load templates.", RemovedInDjango20Warning)
|
||||
"before upgrading to Django 1.10. Otherwise Django will be "
|
||||
"unable to load templates.", RemovedInDjango110Warning)
|
||||
self._templates = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
|
||||
Reference in New Issue
Block a user