ModelForm localize on Select()??

9 views
Skip to first unread message

Christian Schmitt

unread,
May 15, 2013, 7:53:57 AM5/15/13
to django...@googlegroups.com
Hello,

I have a problem with localization and Select() Box, I have the values:
2.00
2.40
3.20
4.00
in my Database, but in Germany we use the number format:
2,00
2,40
3,20
4,00
Now I tried to Localize my modelform with:

class LocalizedModelForm(django.forms.ModelForm):
    def __new__(cls, *args, **kwargs):
        new_class = super(LocalizedModelForm, cls).__new__(cls)
        for field in new_class.base_fields.values():
            if isinstance(field, django.forms.DecimalField):
                field.localize = True
                field.widget.is_localized = True
            if isinstance(field, django.forms.Select):
                field.localize = True
                field.widget.is_localized = True
        return new_class

or even an __init__ with the following:
        self.fields['endintensity'].localize = True
        self.fields['endintensity'].widget.is_localized = True

But i still don't get the localized numbers?
How could i do this correctly??
Reply all
Reply to author
Forward
0 new messages