Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #35436 -- Fixed displaying Unicode chars in postgres.forms.HStoreField #18144

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion django/contrib/postgres/forms/hstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions tests/postgres_tests/test_hstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ class HStoreFormTest(Form):
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):
Expand Down