1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #24338 -- Accepted Template wrapper in {% extends %}.

Explicitly checking for django.template.Template subclasses is
preferrable to duck-typing because both the django.template.Template and
django.template.backends.django.Template have a render() method.

Thanks spectras for the report.
This commit is contained in:
Aymeric Augustin
2015-02-14 10:21:06 +01:00
parent 18c0aaa912
commit 47ee7b48ad
2 changed files with 19 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ from django.contrib.auth.models import Group
from django.core import urlresolvers
from django.template import (
Context, RequestContext, Template, TemplateSyntaxError,
base as template_base, loader,
base as template_base, engines, loader,
)
from django.template.engine import Engine
from django.template.loaders import app_directories, filesystem
@@ -414,6 +414,16 @@ class TemplateRegressionTests(SimpleTestCase):
t1 = Template('{% debug %}')
self.assertIn("清風", t1.render(c1))
def test_extends_generic_template(self):
"""
{% extends %} accepts django.template.backends.django.Template (#24338).
"""
parent = engines['django'].from_string(
'{% block content %}parent{% endblock %}')
child = engines['django'].from_string(
'{% extends parent %}{% block content %}child{% endblock %}')
self.assertEqual(child.render({'parent': parent}), 'child')
class TemplateTagLoading(SimpleTestCase):