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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Martin Burchell's avatar
41
Martin Burchell
updated 13 years ago, asked 13 years ago

Comments

Hmm, this is very odd. Could you take a look which version of Jinja2 library is in the use?
Evgeny's avatar Evgeny (13 years ago)
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 (13 years ago)
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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
updated 13 years ago, answered 13 years ago
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 (13 years ago)
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 (13 years ago)
@Samuel, could you post the trace somewhere, please?
Evgeny's avatar Evgeny (13 years ago)
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 (13 years ago)
No problems, bring up the noise!
Evgeny's avatar Evgeny (13 years ago)
see more comments