my model looks like this:
class MyModel(models.Model): field1 = models.FloatField(default=0) field2 = models.FloatField(default=0)
Here's how he behaves:
>>> m = MyModel() >>> m.full_clean() >>> m = MyModel(field1=8.9) >>> m.full_clean() >>> m = MyModel(field1='') >>> m.full_clean() ValidationError: {'field1': [u'This value must be a float.'], ...
I want him to accept empty strings and use it 0. I also want him to accept values ββlike "5:56" and whether he uses "5.93333". (I already have a function that can do this)
I am currently working with a custom form field (and this is ugly as a sin), but I want to move all this to use model validation. What is the best way to do this?
source share