summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaJH <wogur981208@gmail.com>2024-05-08 22:41:33 +0900
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-05-10 09:42:07 +0200
commitf92ac845a9c75992120a5b5b219e607c19d3f0aa (patch)
treec69deae2e815141469b3eb77d7f753b907b18a4a
parentd59066b90c2ef91a956c6682ed3d25bbb31bf216 (diff)
Fixed #35436 -- Fixed displaying Unicode chars in forms.HStoreField.
-rw-r--r--django/contrib/postgres/forms/hstore.py2
-rw-r--r--tests/postgres_tests/test_hstore.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/django/contrib/postgres/forms/hstore.py b/django/contrib/postgres/forms/hstore.py
index 6a20f7b729..f824f78c3e 100644
--- a/django/contrib/postgres/forms/hstore.py
+++ b/django/contrib/postgres/forms/hstore.py
@@ -20,7 +20,7 @@ class HStoreField(forms.CharField):
def prepare_value(self, value):
if isinstance(value, dict):
- return json.dumps(value)
+ return json.dumps(value, ensure_ascii=False)
return value
def to_python(self, value):
diff --git a/tests/postgres_tests/test_hstore.py b/tests/postgres_tests/test_hstore.py
index 2aaad637c6..cac3eb742a 100644
--- a/tests/postgres_tests/test_hstore.py
+++ b/tests/postgres_tests/test_hstore.py
@@ -410,6 +410,13 @@ class TestFormField(PostgreSQLSimpleTestCase):
form_w_hstore = HStoreFormTest({"f1": '{"a": 2}'}, initial={"f1": {"a": 1}})
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):
def test_simple_valid(self):