Django ModelForm float field not calling Clean_Field method

I have a unique problem. I put the value "90 dollars" in my floatField. I assume that it should be cleaned and saved as "90.0" in the model.

but when I enter "$ 90" and call the clean_filed method, it does not call this clean method. but when I apply a breakpoint on a pure (self) mehthod and try to get its value, it says "No".

please help me. here is my code.

Model
class Project(models.Model):
foo = models.FloatField("foo",
        null=True, blank=True
    )


forms
widgets = {
         'foo': forms.TextInput(attrs={'currency': 'true'})}

    def clean_foo(self):
        value = self.cleaned_data.get('foo')
        print value # i get NONE here.............
        return value 
+4
source share
1 answer

clean_<field> API . , . , clean_<field> . https://docs.djangoproject.com/en/stable/ref/forms/validation/

, Field.clean() ValidationError, , , . .

, $90 float, . FloatField, ( $ ..) float.

+13

All Articles