mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #35436 -- Fixed displaying Unicode chars in forms.HStoreField.
This commit is contained in:
parent
d59066b90c
commit
f92ac845a9
@ -20,7 +20,7 @@ class HStoreField(forms.CharField):
|
|||||||
|
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return json.dumps(value)
|
return json.dumps(value, ensure_ascii=False)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
|
@ -410,6 +410,13 @@ class TestFormField(PostgreSQLSimpleTestCase):
|
|||||||
form_w_hstore = HStoreFormTest({"f1": '{"a": 2}'}, initial={"f1": {"a": 1}})
|
form_w_hstore = HStoreFormTest({"f1": '{"a": 2}'}, initial={"f1": {"a": 1}})
|
||||||
self.assertTrue(form_w_hstore.has_changed())
|
self.assertTrue(form_w_hstore.has_changed())
|
||||||
|
|
||||||
|
def test_prepare_value(self):
|
||||||
|
field = forms.HStoreField()
|
||||||
|
self.assertEqual(
|
||||||
|
field.prepare_value({"aira_maplayer": "Αρδευτικό δίκτυο"}),
|
||||||
|
'{"aira_maplayer": "Αρδευτικό δίκτυο"}',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestValidator(PostgreSQLSimpleTestCase):
|
class TestValidator(PostgreSQLSimpleTestCase):
|
||||||
def test_simple_valid(self):
|
def test_simple_valid(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user