#13010 closed (duplicate)
ModelForm clean() is ignored
Reported by: | Patryk Zawadzki | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.2-beta |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In 1.2 when you validate a form the logic is as follows:
BaseForm
'sfull_clean()
is calledModelForm
's_clean_fields()
is called- it calls each field's
clean_FOO()
- it calls construct_instance and at this point assigns all values to the instance
- it calls each field's
BaseForm
's_clean_form()
is called- it calls
clean()
- it calls
At this point clean() can update self.cleaned_data but the value is never used for anything. This breaks forms that rely on clean() being able to alter the data (useful for example when a field's value depends on other fields). The instance should at least be updated when calling save().
Note:
See TracTickets
for help on using tickets.
Duplicate of #12960.