Màj de django-translated-fields

This commit is contained in:
Tom Hubrecht 2021-04-15 17:26:27 +02:00
parent 7ebbb8d3e8
commit c9c8915ecd
2 changed files with 3 additions and 13 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
django==3.2.*
django-translated-fields==0.11
django-translated-fields==0.11.1
authens>=0.1b2
numpy
networkx