diff --git a/elections/forms.py b/elections/forms.py index 9b1c7bc..0ea9a6d 100644 --- a/elections/forms.py +++ b/elections/forms.py @@ -1,24 +1,14 @@ +from translated_fields import language_code_formfield_callback + from django import forms from django.forms.models import inlineformset_factory from django.utils import timezone -from django.utils.functional import keep_lazy_text -from django.utils.text import capfirst from django.utils.translation import gettext_lazy as _ from .models import Election, Option, Question from .utils import check_csv -# En attendant que ce soit merge dans django-translated-fields -def language_code_formfield_callback(db_field, **kwargs): - language_code = getattr(db_field, "_translated_field_language_code", "") - if language_code: - kwargs["label"] = keep_lazy_text(lambda s: "%s [%s]" % (s, language_code))( - capfirst(db_field.verbose_name) - ) - return db_field.formfield(**kwargs) - - class ElectionForm(forms.ModelForm): formfield_callback = language_code_formfield_callback diff --git a/requirements.txt b/requirements.txt index 6007652..290b5bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ django==3.2.* -django-translated-fields==0.11 +django-translated-fields==0.11.1 authens>=0.1b2 numpy networkx