﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17419	Add a JSON template filter	Lau Bech Lauritzen	Aymeric Augustin	"It's nice to be able to quickly make Python lists and dictionaries into JSON. The normal way of doing this is to dump the data structure as JSON in the view and then outputting the JSON within a script tag in the template, remembering to pipe it through safe. This little addition to Django would streamline that process.

It lets you do this:
{{{
<script>
  var data = {{ data|json }};
</script>
}}}

Instead of:
{{{
views.py:

from django.utils import simplejson 

def home(request):
  data = {'hello: ['world', 'universe']}
  return render_to_response(""home.html"", {
    'data': simplejson.dumps(data),
    }, context_instance=get_context(request))    


home.html:

<script>
  var data = {{ data|safe }};
</script>"	New feature	closed	Template system	dev	Normal	fixed	json template tag	mike@… Florian Apolloner adrian.macneil@… sergeimaertens@… nate-djangoproject@…	Accepted	1	0	0	1	0	0
