Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13010 closed (duplicate)

ModelForm clean() is ignored

Reported by: patrys 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: UI/UX:

Description

In 1.2 when you validate a form the logic is as follows:

  • BaseForm's full_clean() is called
  • ModelForm'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
  • BaseForm's _clean_form() is called
    • it calls clean()

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().

Change History (2)

comment:1 Changed 5 years ago by jkocherhans

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12960.

comment:2 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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