Loading django/template/loader_tags.py +5 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,11 @@ class BlockNode(Node): return result def super(self): if not hasattr(self, 'context'): raise TemplateSyntaxError( "'%s' object has no attribute 'context'. Did you use " "{{ block.super }} in a base template?" % self.__class__.__name__ ) render_context = self.context.render_context if (BLOCK_CONTEXT_KEY in render_context and render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None): Loading tests/template_tests/tests.py +3 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,9 @@ class TemplateTests(TestCase): # Raise exception for custom tags used in child with {% load %} tag in parent, not in child 'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError), # Raise exception for block.super used in base template 'exception05': ("{% block first %}{{ block.super }}{% endblock %}", {}, template.TemplateSyntaxError), ### FILTER TAG ############################################################ 'filter01': ('{% filter upper %}{% endfilter %}', {}, ''), 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), Loading Loading
django/template/loader_tags.py +5 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,11 @@ class BlockNode(Node): return result def super(self): if not hasattr(self, 'context'): raise TemplateSyntaxError( "'%s' object has no attribute 'context'. Did you use " "{{ block.super }} in a base template?" % self.__class__.__name__ ) render_context = self.context.render_context if (BLOCK_CONTEXT_KEY in render_context and render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None): Loading
tests/template_tests/tests.py +3 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,9 @@ class TemplateTests(TestCase): # Raise exception for custom tags used in child with {% load %} tag in parent, not in child 'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError), # Raise exception for block.super used in base template 'exception05': ("{% block first %}{{ block.super }}{% endblock %}", {}, template.TemplateSyntaxError), ### FILTER TAG ############################################################ 'filter01': ('{% filter upper %}{% endfilter %}', {}, ''), 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), Loading