Created
October 16, 2013 03:52
-
-
Save limeyd/7002431 to your computer and use it in GitHub Desktop.
py: tastypie-pretty-json-serializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrettyJSONSerializer(Serializer): | |
json_indent = 2 | |
def to_json(self, data, options=None): | |
options = options or {} | |
data = self.to_simple(data, options) | |
return simplejson.dumps(data, cls=json.DjangoJSONEncoder, | |
sort_keys=True, ensure_ascii=False, indent=self.json_indent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update for Django 1.5+ (see release notes)
Then you just have to wire it to the resource: