First time here? Check out the FAQ!
1

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 http://dpaste.com/561250/

askbot 0.7.3

Does this ring any bells?

Edit:
USE_I18N = True
Settings are at http://dpaste.com/561263/

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
41
Martin Burchell
updated 2011-07-04 04:09:09 -0600, asked 2011-06-30 05:28:47 -0600
edit flag offensive 0 remove flag close merge delete

Comments

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 -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's avatar Evgeny (2011-06-30 13:08:47 -0600) edit
add a comment see more comments

1 Answer

0

Do you have USE_I18N = True in your settings.py?

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 settings.py (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 manage.py shell
>>>import jinja2
>>>jinja2.__version__

Thanks.

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

Comments

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 -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's avatar Evgeny (2011-08-03 09:25:07 -0600) edit
@Samuel, could you post the trace somewhere, please?
Evgeny's avatar Evgeny (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's avatar Samuel (2011-08-04 08:03:05 -0600) edit
No problems, bring up the noise!
Evgeny's avatar Evgeny (2011-08-04 08:03:53 -0600) edit
add a comment see more comments