Hide keyboard shortcuts

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 

2 

3from django import forms 

4from django.utils.translation import ugettext_lazy as _ 

5from .choices import COMMON_LANGUAGE_CHOICES 

6from .constants import MAX_CHOICE_LENGTH 

7 

8# Exports 

9 

10__all__ = ( 

11 "LanguageChoiceField", 

12) 

13 

14# Fields 

15 

16 

17class LanguageChoiceField(forms.ChoiceField): 

18 """A field that presents language choices. 

19 

20 By default, ``COMMON_LANGUAGE_CHOICES`` are used, so passing more or less choices may be desirable instead. 

21 

22 """ 

23 

24 description = _("A field of language choices.") 

25 

26 def __init__(self, *args, **kwargs): 

27 kwargs['max_length'] = MAX_CHOICE_LENGTH 

28 

29 super().__init__(*args, **kwargs) 

30 

31 self.choices = kwargs.get("choices", COMMON_LANGUAGE_CHOICES)