Opened 5 years ago

Closed 4 years ago

Last modified 4 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 gabrielhurley)

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 4 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by gabrielhurley

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by elbarto

  • Owner changed from nobody to elbarto

Changed 4 years ago by elbarto

comment:3 Changed 4 years ago by elbarto

  • Has patch set

comment:4 Changed 4 years ago by timo

  • Resolution set to fixed
  • Status changed from new to closed

(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 4 years ago by timo

(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