fmt = u'{0.value} ({0.min_value}-{0.max_value}) {0.unit}'
return fmt.format(self)
- def validate_amount(self):
+ def clean(self):
if self.value is None:
if self.min_value is None and self.max_value is not None:
raise ValidationError('cannot only set max_value')
raise ValidationError('cannot only set min_value')
if self.value is not None and self.unit is None:
raise ValidationError('values must have units')
+ super(Amount, self).clean()
class Directions (models.Model):
self.amount.min_value = minv
self.amount.max_value = maxv
if valid:
- self.amount.validate_amount()
+ self.amount.clean()
else:
- self.assertRaises(ValidationError, self.amount.format_amount)
+ self.assertRaises(ValidationError, self.amount.clean)