Màj de django-translated-fields
This commit is contained in:
parent
7ebbb8d3e8
commit
c9c8915ecd
2 changed files with 3 additions and 13 deletions
|
@ -1,24 +1,14 @@
|
||||||
|
from translated_fields import language_code_formfield_callback
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
from django.utils import timezone
|
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 django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from .models import Election, Option, Question
|
from .models import Election, Option, Question
|
||||||
from .utils import check_csv
|
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):
|
class ElectionForm(forms.ModelForm):
|
||||||
formfield_callback = language_code_formfield_callback
|
formfield_callback = language_code_formfield_callback
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
django==3.2.*
|
django==3.2.*
|
||||||
django-translated-fields==0.11
|
django-translated-fields==0.11.1
|
||||||
authens>=0.1b2
|
authens>=0.1b2
|
||||||
numpy
|
numpy
|
||||||
networkx
|
networkx
|
||||||
|
|
Loading…
Reference in a new issue