mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #25466 -- Added backwards compatibility aliases for LoaderOrigin and StringOrigin.
Thanks Simon Charette for the DeprecationInstanceCheck class.
This commit is contained in:
@@ -58,7 +58,8 @@ from .exceptions import TemplateDoesNotExist, TemplateSyntaxError # NOQA i
|
||||
|
||||
# Template parts
|
||||
from .base import ( # NOQA isort:skip
|
||||
Context, Node, NodeList, Origin, RequestContext, Template, Variable,
|
||||
Context, Node, NodeList, Origin, RequestContext, StringOrigin, Template,
|
||||
Variable,
|
||||
)
|
||||
|
||||
# Library management
|
||||
|
||||
@@ -59,6 +59,9 @@ from django.template.context import ( # NOQA: imported for backwards compatibil
|
||||
BaseContext, Context, ContextPopException, RequestContext,
|
||||
)
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import (
|
||||
DeprecationInstanceCheck, RemovedInDjango20Warning,
|
||||
)
|
||||
from django.utils.encoding import (
|
||||
force_str, force_text, python_2_unicode_compatible,
|
||||
)
|
||||
@@ -156,6 +159,11 @@ class Origin(object):
|
||||
)
|
||||
|
||||
|
||||
class StringOrigin(six.with_metaclass(DeprecationInstanceCheck, Origin)):
|
||||
alternative = 'django.template.Origin'
|
||||
deprecation_warning = RemovedInDjango20Warning
|
||||
|
||||
|
||||
class Template(object):
|
||||
def __init__(self, template_string, origin=None, name=None, engine=None):
|
||||
try:
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import (
|
||||
DeprecationInstanceCheck, RemovedInDjango20Warning,
|
||||
)
|
||||
|
||||
from . import engines
|
||||
from .base import Origin
|
||||
from .exceptions import TemplateDoesNotExist
|
||||
|
||||
|
||||
@@ -57,3 +63,8 @@ def render_to_string(template_name, context=None, request=None, using=None):
|
||||
|
||||
def _engine_list(using=None):
|
||||
return engines.all() if using is None else [engines[using]]
|
||||
|
||||
|
||||
class LoaderOrigin(six.with_metaclass(DeprecationInstanceCheck, Origin)):
|
||||
alternative = 'django.template.Origin'
|
||||
deprecation_warning = RemovedInDjango20Warning
|
||||
|
||||
Reference in New Issue
Block a user