I've got a django model with a field that i want to be always greater than the previous one of the same model instance after an update, like this:
class MyModel(models.Model):
version = models.FloatField()
prev_value = 0
def clean(self):
if self.version <= self.prev_value:
raise ValidationError('error msg')
def save(self,*args,**kwargs):
super(MyModel, self).save(*args, **kwargs)
self.prev_value = self.version
i know that clean is working fine because i've got other validation on the same methon and it's working just fine, what i'm doing wrong and how can i fix it ?. thanks in advance.
I tested it and it didn't throws any error messages on updates with verion < prev_value
Edit: im using new django 1.4