Ask Your Question
1

Error '_' is undefined

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

Martin Burchell gravatar image

updated 2011-07-04 04:09:09 -0500

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.

edit retag flag offensive close merge delete

Comments

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 -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 gravatar imageEvgeny ( 2011-06-30 13:08:47 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

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

Evgeny gravatar image

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

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.

edit flag offensive delete link more

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

Stats

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

Seen: 568 times

Last updated: Jul 04 '11