inclusion of json_pretty for dumping with better UTF8 handling
authorBryan <btbonval@gmail.com>
Tue, 14 Jan 2014 03:36:29 +0000 (03:36 +0000)
committerBryan <btbonval@gmail.com>
Tue, 14 Jan 2014 03:36:29 +0000 (03:36 +0000)
karmaworld/apps/serializers/__init__.py [new file with mode: 0644]
karmaworld/apps/serializers/json_pretty.py [new file with mode: 0644]
karmaworld/settings/common.py

diff --git a/karmaworld/apps/serializers/__init__.py b/karmaworld/apps/serializers/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/karmaworld/apps/serializers/json_pretty.py b/karmaworld/apps/serializers/json_pretty.py
new file mode 100644 (file)
index 0000000..5cbe522
--- /dev/null
@@ -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 <app_name>
+
+"""
+
+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
index 568f7f6ab80e8bc6974ddb408db4c7d32524fa42..fea3ae22dc21dc04fbaf84ffc92234e2e3200186 100644 (file)
@@ -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.