ModelForm save() behavior contradicts with Model object validation documentation.
|Reported by:||vinod@…||Owned by:||nobody|
|Severity:||Normal||Keywords:||modelform validation save model object|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The documentation at http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objectsstates that:
"Note that full_clean() will not be called automatically when you call your model’s save() method, nor as a result of ModelForm validation."
However, this is contradicted by the documentation at http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ that states that:
"Note that save() will raise a ValueError if the data in the form doesn't validate -- i.e., if form.errors evaluates to True."
It appears that save() shouldn't check validation. That's what is_valid() does, throwing a ValidationError if necessary.
Change History (7)
comment:1 Changed 5 years ago by ramiro
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted