Ask Your Question

Error '_' is undefined

asked 2011-06-30 05:28:47 -0600

Martin Burchell gravatar image

updated 2011-07-04 04:09:09 -0600

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.

edit retag flag offensive close merge delete


Hmm, this is very odd. Could you take a look which version of Jinja2 library is in the use?
Evgeny gravatar imageEvgeny ( 2011-06-30 13:07:46 -0600 )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 gravatar imageEvgeny ( 2011-06-30 13:08:47 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-06-30 05:40:05 -0600

Evgeny gravatar image

updated 2011-06-30 17:04:56 -0600

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


edit flag offensive delete link more


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 gravatar imageSamuel ( 2011-08-03 09:19:59 -0600 )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 gravatar imageEvgeny ( 2011-08-03 09:25:07 -0600 )edit
@Samuel, could you post the trace somewhere, please?
Evgeny gravatar imageEvgeny ( 2011-08-03 09:51:53 -0600 )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 gravatar imageSamuel ( 2011-08-04 08:03:05 -0600 )edit
No problems, bring up the noise!
Evgeny gravatar imageEvgeny ( 2011-08-04 08:03:53 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-06-30 05:28:47 -0600

Seen: 560 times

Last updated: Jul 04 '11