i have overwritten clean()
methods of models construct constraints meet db schema requirements (because required runtime information validations).
since have finished of back-end side components(models, signals, ..) i'm trying write modelform
s models.
what i'm wondering that, there relationship between clean()
method of model , clean()
implementation on form side?
if , form's clean()
calls model's clean()
won't have rewrite model - side clean()
implementation , able avoid code redundancy.
yes, modelform
cleaning involves model cleaning. that's idea modelform
: there a lot of useful defaults can determined auto building form object model.
i've discovered clean chaining through personal experience, can reference source.
on 1.8, modelform
s call model instance full_clean
method. on 1.7, calls clean
method directly.
form.full_clean()
def full_clean(self): # ..... snip self._clean_fields() self._clean_form() self._post_clean()
modelform._post_clean 1.8
model full_clean()
calls clean()
amongst other validation: https://docs.djangoproject.com/en/1.8/ref/models/instances/
self.instance.full_clean(exclude=exclude, validate_unique=false)
modelform._post_clean 1.7
self.instance.clean()