Login

utf8-friendly dumpdata management command (no escape symbols) #3

Author:
inductor
Posted:
May 5, 2013
Language:
Python
Version:
1.5
Score:
2 (after 2 ratings)

The version of snippet that works with Django 1.5. Kudos to kmike for the original snippet.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# serializers/json_pretty.py
"""
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

More like this

  1. Treat empty value on DateRangeFilter as a filter for non filled dates by kmmbvnr 1 month, 1 week ago
  2. Django Settings Assignment Expressions aka Walrus Operator example by webology 2 months, 1 week ago
  3. codigo alto nivel by MrRocklion 4 months ago
  4. Load template from specific app by Krzysiek555 4 months, 3 weeks ago
  5. PostgreSQL JSON subqueries by dolamroth 4 months, 3 weeks ago

Comments

Please login first before commenting.