mirror of
https://github.com/django/django.git
synced 2025-07-19 03:05:32 +00:00
Fixed #26917 -- Fixed crash in disabled ModelChoiceFields.
Partially reverted refs #25532 to fix a regression in Django 1.10. This reintroduces a crash for disabled forms.JSONField (refs #26949), however, that issue is also present on Django 1.9. Thanks Ryan Schave for the test.
This commit is contained in:
parent
0d1218896f
commit
a5f85d891b
3 changed files with 19 additions and 13 deletions
|
@ -260,14 +260,6 @@ 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('["foo"]</textarea>', form.as_p())
|
||||
|
||||
def test_prepare_value(self):
|
||||
field = forms.JSONField()
|
||||
self.assertEqual(field.prepare_value({'a': 'b'}), '{"a": "b"}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue