Opened 7 years ago

Last modified 10 months ago

#28589 assigned Cleanup/optimization

When saving in admin, readonly fields are potentially overwritten — at Version 4

Reported by: Fingal Plumpton Owned by: Fingal Plumpton
Component: contrib.admin Version: dev
Severity: Normal Keywords: Admin SQL Overwrite
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Fingal Plumpton)

On the admin page for a model, if a field is in readonly_fields or has editable=False, then saving that model from the admin will create an SQL query that sets the readonly field to it's value at the time the save button was clicked. This field might have been changed (e.g. by a command or some other process) during the time that the model is being saved, and with current behaviour it would then be overwritten to it's old value.

Correct behaviour would be to not set the readonly/uneditable field at all in the SQL query.

The exception to this is a DateTimeField with auto_now or auto_now_add, which have editable=False but should be updated when the SQL query is made.

Change History (4)

comment:1 by Fingal Plumpton, 7 years ago

Owner: changed from nobody to Fingal Plumpton
Status: newassigned

comment:2 by Fingal Plumpton, 7 years ago

Summary: When saving in admin, readonly fields are saved againWhen saving in admin, readonly fields are potentially overwritten

comment:3 by Fingal Plumpton, 7 years ago

Description: modified (diff)

comment:4 by Fingal Plumpton, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top