Opened 14 years ago

Closed 12 years ago

#15591 closed Bug (fixed)

ModelForm save() behavior contradicts with Model object validation documentation.

Reported by: vinod@… Owned by: nobody
Component: Documentation Version: 1.2
Severity: Normal Keywords: modelform validation save model object
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 by Ramiro Morales, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Luke Plant, 14 years ago

Type: Bug

comment:3 by Luke Plant, 14 years ago

Severity: Normal

comment:4 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Tim Graham, 12 years ago

Actually the docs are correct, but I'll add some clarifying text.

comment:7 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In d3fd8a151231726adacb99bdbcd573f95ce32262:

Fixed #15591 - Clarified interaction between ModelForm and model validation.

Note: See TracTickets for help on using tickets.
Back to Top