Login

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

Author:
inductor
Posted:
May 5, 2013
Language:
Python
Version:
1.5
Tags:
fixtures management dumpdata
Score:
1 (after 1 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. utf8-friendly dumpdata management command (no escape symbols) #2 by kmike 3 years, 11 months ago
  2. utf8-friendly dumpdata management command for yaml (no escape symbols) by mucius 1 year, 9 months ago
  3. streaming dump_data by kcarnold 5 years, 11 months ago
  4. streaming serializer by kcarnold 5 years, 11 months ago
  5. Easier custom Model Manager Chaining by gsakkis 4 years, 7 months ago

Comments

Please login first before commenting.