Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Imports
3from django import forms
4from django.utils.translation import ugettext_lazy as _
5from .choices import COMMON_LANGUAGE_CHOICES
6from .constants import MAX_CHOICE_LENGTH
8# Exports
10__all__ = (
11 "LanguageChoiceField",
12)
14# Fields
17class LanguageChoiceField(forms.ChoiceField):
18 """A field that presents language choices.
20 By default, ``COMMON_LANGUAGE_CHOICES`` are used, so passing more or less choices may be desirable instead.
22 """
24 description = _("A field of language choices.")
26 def __init__(self, *args, **kwargs):
27 kwargs['max_length'] = MAX_CHOICE_LENGTH
29 super().__init__(*args, **kwargs)
31 self.choices = kwargs.get("choices", COMMON_LANGUAGE_CHOICES)