# Imports
from django import forms
from django.utils.translation import gettext_lazy as _
from .choices import COMMON_LANGUAGE_CHOICES
from .constants import LANGUAGE_MAX_CHOICE_LENGTH
# Exports
__all__ = (
"LanguageChoiceField",
)
# Fields
[docs]class LanguageChoiceField(forms.ChoiceField):
"""A field that presents language choices.
By default, ``COMMON_LANGUAGE_CHOICES`` are used, so passing more or less choices may be desirable instead.
"""
description = _("A field of language choices.")
[docs] def __init__(self, **kwargs):
choices = kwargs.pop("choices", COMMON_LANGUAGE_CHOICES)
super().__init__(choices=choices, **kwargs)