Opened 7 months ago

Closed 7 months ago

#30534 closed Bug (fixed)

Allow `cleaned_data` to overwrite fields' default values.

Reported by: Robin (Robert) Thomas Owned by: Robin (Robert) Thomas
Component: Forms Version: master
Severity: Normal Keywords: forms, models
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

See comments here: https://github.com/django/django/pull/7068/files#r289432409

Currently, when submitting a form, if 'some_field' isn't in the data payload (e.g. it wasn't included in the form, perhaps because its value is derived from another field), and 'some_field' has a default value on the model, it cannot be overwritten with 'self.cleaned_data'.

This does not really follow the paradigm of modifying data in 'cleaned_data'. It requires the user to copy and overwrite the raw data submitted with the form.

Change History (2)

comment:1 Changed 7 months ago by felixxm

Has patch: set
Owner: changed from nobody to Robin (Robert) Thomas
Status: newassigned
Summary: ModelForms: Allow `cleaned_data` to overwrite fields' default valuesAllow `cleaned_data` to overwrite fields' default values.
Triage Stage: UnreviewedAccepted
Type: New featureBug
Version: 2.2master

comment:2 Changed 7 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In aa94f7c8:

Fixed #30534 -- Fixed overriding a field's default in ModelForm.cleaned_data().

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