﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15535	{% blocktrans %} tag raises KeyErrors while rendering	Stephen Burrows	nobody	"Blocktrans allows variables to be nested inside of it; however, if one of those variables is not defined in the context, a !KeyError will be raised during the render of the block node. Ex:
{{{
{% blocktrans %}{{ not_defined }}{% endblocktrans %}
}}}

This can be seen by using the manage.py shell:
{{{#!python
>>> from django.template import Template, Context
 >>> t = Template(""{% load i18n %}{% blocktrans %}{{ not_defined }}{% endblocktrans %}"")
>>> c = Context()
>>> t.render(c)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File "".../django/template/base.py"", line 123, in render
    return self._render(context)
  File "".../django/template/base.py"", line 117, in _render
    return self.nodelist.render(context)
  File "".../django/template/base.py"", line 744, in render
    bits.append(self.render_node(node, context))
  File "".../django/template/debug.py"", line 73, in render_node
    result = node.render(context)
  File "".../django/templatetags/i18n.py"", line 116, in render
    data = dict([(v, _render_value_in_context(context[v], context)) for v in vars])
  File "".../django/template/context.py"", line 60, in __getitem__
    raise KeyError(key)
TemplateSyntaxError: Caught KeyError while rendering: not_defined
>>>
}}}

According to the docs, template tags should never raise errors during their render method. ![1] My patch attempts to address this by adding the empty string as a failobj for each attempt to get a variable from the context. I'm not familiar with how exactly the internationalization framework works, so this may be an inappropriate way of handling things; however, no tests fail after adding the patch.

![1] http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-the-renderer"		closed	Internationalization	dev		fixed	blocktrans		Unreviewed	1	0	0	0	0	0
