First time here? Check out the FAQ!

Error '_' is undefined

I'm not sure what I've done here (maybe messed up my configuration) but I'm seeing this error:

Exception Type: UndefinedError at /forum/questions/
Exception Value: '_' is undefined

Full trace at

askbot 0.7.3

Does this ring any bells?

USE_I18N = True
Settings are at

Also the other pages work fine eg tags, people, badges and I can see the French translation. It's just the questions page that shows this problem.

Edit: Replacing _() with gettext() in tab_bar.html fixes the problem. Using jinja2 2.5.5.

Martin Burchell's avatar
Martin Burchell
updated 2011-07-04 04:09:09 -0500, asked 2011-06-30 05:28:47 -0500
edit flag offensive 0 remove flag close merge delete


Hmm, this is very odd. Could you take a look which version of Jinja2 library is in the use?
Evgeny's avatar Evgeny (2011-06-30 13:07:46 -0500) edit
Could you also try replacing _() with gettext() calls in the template askbot/skins/default/templates/main_page/tab_bar.html - will that help?
Evgeny's avatar Evgeny (2011-06-30 13:08:47 -0500) edit
add a comment see more comments

1 Answer


Do you have USE_I18N = True in your

The complaint on _ is not defined probably points at translation module not being imported.

Also - do you have any customization on your site? Maybe you could dpaste your (excluding any potentially sensitive info?)

edit is it possible that your version of jinja2 does not support the _ alias to gettext? Could you tell what is the jinja2 library version on your machine?

python shell
>>>import jinja2


Evgeny's avatar
updated 2011-06-30 17:04:56 -0500, answered 2011-06-30 05:40:05 -0500
edit flag offensive 0 remove flag delete link


I had the same issue with Jinja2 2.6 which has been deployed automatically as a dependency when I have deployed askbot with pip in python 2.6 on RHEL 5.5 this morning.
Samuel's avatar Samuel (2011-08-03 09:19:59 -0500) edit
Samuel, where do you get this error - I cannot find use of _() function anywhere in the templates. Is the error thrown from a .py file?
Evgeny's avatar Evgeny (2011-08-03 09:25:07 -0500) edit
@Samuel, could you post the trace somewhere, please?
Evgeny's avatar Evgeny (2011-08-03 09:51:53 -0500) edit
my rebase on the github master branch was anterior to the fix you did in tab_bar.html. Sorry for the noise generated.
Samuel's avatar Samuel (2011-08-04 08:03:05 -0500) edit
No problems, bring up the noise!
Evgeny's avatar Evgeny (2011-08-04 08:03:53 -0500) edit
add a comment see more comments