I have a model M that has a field num=models.IntegerField()
I have a modelform called F for model M.
I want to ensure that num is never negative.
If I do validation in my form class, F, then I can do clean_num():
if negative then throw ValidationError('Num can never be negative').
This ValidationError will be automatically redisplayed to the user by
redirecting him to back to the form that he submitted and displaying
the 'Num can never be negative' message on top of the num field.
Thats all done automatically by django as soon as I throw the
ValidationError from the clean_fieldname method.
I would like to be able to do all that, but in the model class.
F is the ModelForm created from a model class M. M defines that
the field num can never be negative.
When I'm calling is_valid() on a form, I want the functions defined in the model
to check for validation for any ModelForm that references this model.
How can I achieve this?