Задать вопрос

Тел: +7 965 3737 888

440

Просмотров

2

Ответов

LanguageField

How to use: simple as a CharField.

Вопрос полезен? Да0/Нет0
file_5067.py(355.0б)
None

Ответы (2):

Ответjeverling:16.05.2012
Ответ полезен? Да0/Нет0

Although this snippet is rather old, it still works fine... :) If you want to use I18N, you should use this:

from django.utils import translation
kwargs.setdefault('choices', [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES])

Also, 5 chars is not enough anymore, for example sr-latn has 7.

Ответaguafuertes:09.07.2009
Ответ полезен? Да0/Нет0

Thanks for the snippet.

A little typo: in Line 5 it must be 'max_length' instead of 'maxlength'