﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26110	Admin form escapes postgres JSONField on ValidationError	Rubén Díaz	nobody	"To reproduce this bug, let's assume we have this model:

{{{#!python
class TestModel(models.Model):
    test_url = models.URLField()  # I've chosen URLField as an example but the specific type of field is irrelevant for this issue
    json_field = JSONField(default={})
}}}

The model is added to the admin site the standard way (`admin.site.register()`) so that we can add content easily. Now, if you go and submit the following:

`test_url` → `test`
`json_field` → `{""hello"": ""hola""}`

It'll trigger an expected `ValidationError` since it's not a valid URL. When the form is rendered and presented back to the user, the `test_url` will show the incorrect URL while the `json_field` will look like this: `""{\""hello\"": \""hola\""}""`. If the user corrects the `test_url` and submits the form again, the `json_field` that's being stored in the DB will be the escaped one.

I can't say if this only happens with admin forms or any form (e.g. model forms) since I have no time to run proper tests, but I hope this is enough to track down the issue."	Bug	closed	contrib.admin	1.9	Normal	duplicate	jsonfield, admin		Unreviewed	0	0	0	0	0	0
