summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorOlexander Yermakov <mannavard1611@gmail.com>2016-07-26 08:18:08 -0400
committerTim Graham <timograham@gmail.com>2016-07-27 08:43:07 -0400
commit714e287d9a2b8ca7668a951e7193d9bbae3c3162 (patch)
tree58c4347be03d18afe620570ffea3d9902c64c48c /tests/postgres_tests
parent3744fc1666c41aeb4ed44f31605bafdb413b42bc (diff)
[1.10.x] Fixed #26949 -- Fixed crash of disabled forms.JSONField.
Backport of 68de48c96328e13d5dbdb1f3006e4a1ca74f3c34 from master
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_json.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_json.py b/tests/postgres_tests/test_json.py
index d4f0a9bb57..1978552cf9 100644
--- a/tests/postgres_tests/test_json.py
+++ b/tests/postgres_tests/test_json.py
@@ -260,6 +260,14 @@ class TestFormField(PostgreSQLTestCase):
form_field = model_field.formfield()
self.assertIsInstance(form_field, forms.JSONField)
+ def test_formfield_disabled(self):
+ class JsonForm(Form):
+ name = CharField()
+ jfield = forms.JSONField(disabled=True)
+
+ form = JsonForm({'name': 'xyz', 'jfield': '["bar"]'}, initial={'jfield': ['foo']})
+ self.assertIn('[&quot;foo&quot;]</textarea>', form.as_p())
+
def test_prepare_value(self):
field = forms.JSONField()
self.assertEqual(field.prepare_value({'a': 'b'}), '{"a": "b"}')