Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#20076 closed Uncategorized (worksforme)

Admin read-only fields should be included in POST

Reported by: Jonas H. Owned by: nobody
Component: contrib.admin Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Fields marked readonly in the admin are not included in the POST in case the model is saved. Now if such field does not have @blank=True@, the form doesn't validate since a non-blank field is missing a value.

These values should be included in the form as hidden fields.

Change History (2)

comment:1 Changed 5 years ago by Karen Tracey

Resolution: worksforme
Status: newclosed

Fields listed in readonly_fields are excluded from the default model form build by the admin, therefore they do not need to be in POST in order for the form validation and model save to succeed, see I just tried this and it works fine to edit-and-save a model with a readonly field (that already has a value in the field), there is something beyond a simple readonly field and default admin here that led to the assertion that values were needed in POST. Without knowing the specifics of the situation though, it's hard to guess whether there is a bug in Django or a mis-use/misconfiguation in the model admin using readonly_fields.

comment:2 Changed 5 years ago by Jonas H.

Sorry. Seems to have been an issue with my code.

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