From: Bryan Date: Tue, 14 Jan 2014 03:36:29 +0000 (+0000) Subject: inclusion of json_pretty for dumping with better UTF8 handling X-Git-Tag: release-20150131~272 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=90775067e14ea4017e2702a66b933a1a8365826e;p=oweals%2Fkarmaworld.git inclusion of json_pretty for dumping with better UTF8 handling --- diff --git a/karmaworld/apps/serializers/__init__.py b/karmaworld/apps/serializers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/karmaworld/apps/serializers/json_pretty.py b/karmaworld/apps/serializers/json_pretty.py new file mode 100644 index 0000000..5cbe522 --- /dev/null +++ b/karmaworld/apps/serializers/json_pretty.py @@ -0,0 +1,20 @@ +# Snippet from +# https://djangosnippets.org/snippets/2916/ +""" +Add the line to settings.py:: + + SERIALIZATION_MODULES = {'json-pretty': 'serializers.json_pretty'} + +And call dumpdata as follows:: + + ./manage.py dumpdata --format=json-pretty + +""" + +from django.core.serializers.json import Serializer as JSONSerializer + + +class Serializer(JSONSerializer): + def start_serialization(self): + super(Serializer, self).start_serialization() + self.json_kwargs['ensure_ascii'] = False diff --git a/karmaworld/settings/common.py b/karmaworld/settings/common.py index 568f7f6..fea3ae2 100644 --- a/karmaworld/settings/common.py +++ b/karmaworld/settings/common.py @@ -15,6 +15,9 @@ from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api FILEPICKER_API_KEY = fp_api +SERIALIZATION_MODULES = {'json-pretty': 'karmaworld.apps.serializers.json_pretty'} + + ########## REQUIRED SECURITY CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS # The hosts that this server runs from.