Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

fix bug: admin throws json exception when we edit the map #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion leaflet_storage/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_prep_value(self, value):
if not value:
value = {}
if not isinstance(value, six.string_types):
value = json.dumps(value)
value = json.dumps(value, ensure_ascii=False)
return value

def from_db_value(self, value, expression, connection, context):
Expand All @@ -26,3 +26,10 @@ def to_python(self, value):
return json.loads(value)
else:
return value

def value_from_object(self, obj):
"""
Returns the value of this field in the given model instance.
"""
value = getattr(obj, self.attname)
return json.dumps(value, ensure_ascii=False) if value is not None else ''