{{{
'BlockNode' object has no attribute 'context'
}}}
It is thrown in `super` method when doing:
{{{
render_context = self.context.render_context
}}}
I think code should check for missing `self.context` and throw a more
informative exception.
--
Ticket URL: <https://code.djangoproject.com/ticket/21707>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* version: 1.4 => master
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:1>
* owner: nobody => anubhav9042
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:2>
* has_patch: 0 => 1
Comment:
I have added a small patch which raises TemplateSyntaxError.
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:3>
* cc: timo (added)
* needs_better_patch: 0 => 1
Comment:
I would hope there's a more specific way to detect this problem than
catching all AttributeErrors. Also `TemplateSyntaxError` should include a
helpful message.
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:4>
Comment (by anubhav9042):
Sure.
I just had a quick look. I'll add a better patch soon.
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:5>
Comment (by anubhav9042):
Changed the position where I handled `AttributeError`
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:6>
Comment (by timo):
Rather than try/except, it would probably be better to do:
{{{
if not hasattr(self, 'context'):
raise TemplateSyntaxError(...)
}}}
And make the message less definitive (e.g. include the original exception
message and add "Did you use {{ block.super }} in a base template?". I am
not sure, but there might be other cases where context could be missing so
including the original exception could be helpful just in case.
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:7>
* needs_better_patch: 1 => 0
Comment:
https://github.com/django/django/pull/2949
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"b1abfb3c59467d0bb088e19be76fc42fcb570835"]:
{{{
#!CommitTicketReference repository=""
revision="b1abfb3c59467d0bb088e19be76fc42fcb570835"
Fixed #21707 -- Added helpful error message when using {{ block.super }}
in base template.
Thanks mitar for the suggestion.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21707#comment:9>