Skip to content

Commit

Permalink
fix for Django 1.5 for json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nick2k5 committed Apr 11, 2013
1 parent 49b609c commit 8b56e34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion simple_rest/utils/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def to_json(content, indent=None):
json_serializer = serializers.get_serializer('json')()
serialized_content = json_serializer.serialize(content, ensure_ascii=False, indent=indent)
else:
serialized_content = json.dumps(content, cls=DecimalEncoder, ensure_ascii=False, indent=indent)
try:
serialized_content = json.dumps(content, cls=DecimalEncoder, ensure_ascii=False, indent=indent)
except TypeError:
# Fix for Django 1.5
serialized_content = json.dumps(content, ensure_ascii=False, indent=indent)
return serialized_content


Expand Down

0 comments on commit 8b56e34

Please sign in to comment.