views:

11

answers:

1

Hi guys, Django newbie here,

I'm using Django's i18n to translate my website.

My templates get translated just fine using the trans template tag

However, when I try to translate strings in my python files, for instance this form field's label:

from django.utils.translation import gettext as _

class RegForm(forms.Form):
    form_field = forms.CharField(label=_('My field'))

It does not get translated. The same page contains other template strings that do get translated..

Any ideas?

A: 

The solution is to use ugettext_lazy instead of gettext

apple_pie