From c9c8915ecd9b5c38977ae95f6b4f1b2985c9c430 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 15 Apr 2021 17:26:27 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A0j=20de=20django-translated-fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/forms.py | 14 ++------------ requirements.txt | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) 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