djangosnippets.org: Latest snippets posted by oldcaihttps://djangosnippets.org/users/oldcai/2017-10-07T09:58:48.674711-05:00oldcaiDo Not Escape Characters When Using dumpdata Command (Tested in Django 1.11)
2017-10-07T09:58:48.674711-05:00oldcaihttps://djangosnippets.org/snippets/10625/<p>Adds <code>--pretty</code> option to django <code>./manage.py dumpdata</code> command, which produces pretty utf-8 strings instead of ugly unicode-escaped s**t:</p>
<blockquote>
<p>$ ./manage.py dumpdata app.pricingplan --indent=1</p>
</blockquote>
<pre><code>[
{
"pk": 1,
"model": "app.pricingplan",
"fields": {
"name": "\u0411\u0430\u0437\u043e\u0432\u044b\u0439",
}
},
{
"pk": 2,
"model": "app.pricingplan",
"fields": {
"name": "\u0425\u0443\u044f\u0437\u043e\u0432\u044b\u0439",
}
}
]
</code>
</pre>
<blockquote>
<p>./manage.py dumpdata app.pricingplan …</p></blockquote>
Freely redistributable