Ticket #21707: 21707_patch2.diff

File 21707_patch2.diff, 1.6 KB (added by ANUBHAV JOSHI, 10 years ago)
  • django/template/loader_tags.py

    diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
    index 77508a7..20688ee 100644
    a b class BlockNode(Node):  
    6868        return result
    6969
    7070    def super(self):
    71         render_context = self.context.render_context
     71        try:
     72            render_context = self.context.render_context
     73        except AttributeError:
     74            raise TemplateSyntaxError("No parent block found for 'super'.")
    7275        if (BLOCK_CONTEXT_KEY in render_context and
    7376                render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None):
    7477            return mark_safe(self.render(self.context))
  • tests/template_tests/tests.py

    diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
    index e785962..84b6592 100644
    a b class TemplateTests(TestCase):  
    881881            # Raise exception for custom tags used in child with {% load %} tag in parent, not in child
    882882            'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError),
    883883
     884            # Raise exception for block.super used in base template
     885            'exception05': ("{% block first %}{{ block.super }}{% endblock %}", {}, template.TemplateSyntaxError),
     886
    884887            ### FILTER TAG ############################################################
    885888            'filter01': ('{% filter upper %}{% endfilter %}', {}, ''),
    886889            'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'),
Back to Top