djangosnippets.org: Latest snippets tagged with 'pretty-print'https://djangosnippets.org/tags/pretty-print/2017-10-07T09:58:48.674711-05:00Do 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 redistributablePretty Print Template Tag
2014-05-22T03:49:30.679324-05:00paulvrutledgehttps://djangosnippets.org/snippets/3058/<p>This defines a new template tag that lets you print your rendered templates (or partial templates) in html that has been prettified by beautiful soup. It is dependent on the beautiful soup library (bs4). Not recommended for production but it is helpful for development and serving readable html.</p>
<pre><code>{% load …</code></pre>
Freely redistributable