Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13949 closed (fixed)

readonly fields can't be modified via cleaned_data in forms

Reported by: alk Owned by: elbarto
Component: Documentation Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Gabriel Hurley)

if you make a model with readonly fields, the value of that field can't be set in a clean() validator in that model's form - this isn't mentioned in the documentation anywhere as far as I can see, should be added I think

Attachments (1)

patch.diff (768 bytes) - added by elbarto 6 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 6 years ago by Gabriel Hurley

Description: modified (diff)
Triage Stage: UnreviewedAccepted

It's true that the data for read-only fields are not available in cleaned_data. This is because read-only fields are displayed as text rather than as input elements, and thus are not posted back to the server, and so are not in the data that gets cleaned.

Mentioning this fact couldn't hurt.

comment:2 Changed 6 years ago by elbarto

Owner: changed from nobody to elbarto

Changed 6 years ago by elbarto

Attachment: patch.diff added

comment:3 Changed 6 years ago by elbarto

Has patch: set

comment:4 Changed 6 years ago by Tim Graham

Resolution: fixed
Status: newclosed

(In [15060]) Fixed #13949 - Note that readonly fields can't be modified via custom clean methods. thanks alk for the suggestion and elbarto and Gabriel Hurley whose language I used in the final patch.

comment:5 Changed 6 years ago by Tim Graham

(In [15061]) [1.2.X] Fixed #13949 - Note that readonly fields can't be modified via custom clean methods. thanks alk for the suggestion and elbarto and Gabriel Hurley whose language I used in the final patch.

Backport of r15060 from trunk.

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