Allow JSONFields to be modified through the admin UI.
Review Request #4891 — Created Nov. 4, 2013 and submitted
Allow JSONFields to be modified through the admin UI.
At times, people would try to set new content in a JSONField in the
admin UI, since the field is editable. This resulted in a broken
encoded string that had to be literal_eval'd. It was also pretty easy to
accidentally lose the payload by introducing JSON syntax errors without
any warning.Now a JSONField will store the string as-is if one is passed, instead of
assuming it's structured data it needs to be encoded and stored. To
ensure the data it's trying to set is valid, it also runs a validator
that guarantees input going in is valid JSON. Invalid JSON will result
in a validation error in the form.
Tested entering valid and invalid data in the admin UI, while watching
console output.Valid data saved correctly, and I no longer had the decode warnings.
Invalid data resulted in a validation error in the admin UI, telling me
exactly what was wrong (according to the json module).