Description

I have a custom field in a model (in this case JSONField, but I also reproduced this with PickledObjectField). If I run a query on that model in which I defer() the custom field and then save() that model, the custom field value gets corrupted. The models.py and tests.py code below reproduces this issue.

When the save() is called, Django retrieves the deferred field through a select statement. But when it executes the update statement, it incorrectly stores that field back into the database. If you look at the value of the data column, it goes from [1,2,3] to "[1,2,3]" (yes, the change is the quotes).