forms.py : To get the translations for the fields' labels, use ugettext_lazy() instead for ugettext().

ugettext() loads the translations at the same time the module is loaded (--> always in english).
ugettext_lazy() loads them when they are needed (--> when the user makes a query --> we known the language the user wants based on the header of their HTTP request)

Signed-off-by: Jerome Flesch <jflesch@gmail.com>
This commit is contained in:
Jerome Flesch 2016-10-18 15:37:57 +02:00
parent 0ad110ec7f
commit 74668f30d5

View File

@ -15,7 +15,7 @@ from django import forms
from django.forms import extras from django.forms import extras
from django.core.files.storage import default_storage from django.core.files.storage import default_storage
from django.conf import settings from django.conf import settings
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext_lazy as _
try: try:
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
User = get_user_model() User = get_user_model()