How to get rid of 'quot' in Python json.dumps

django, javascript, json, python

Solution

As Armance says in the comments, you need to mark the variable as safe in the template so it is not escaped:

{{ myJson|safe }}

Problem

In Django, I have a view that requests a JSON feed and renders the response along with a template. I need to convert the JSON object to a Javascript JSON object. I have managed to console.log the JSON object in my template, but something is wrong with the format. This is what I expect: ``` {"lat": 58.548703, "referenceTime": "2013-12-05T07:00:00Z", "lon": 16.155116... ``` and this is what I get: ``` {"lat": 58.548703, "referenceTime": "2013-12-05T07:00:00Z", "lon": 16.155116... ``` Here is my view: ``` def myView(request): request = Request('http://somedomain/somefeed.json') response = urlopen(request) data = json.load(response) return render_to_response('myTemplate.html', {'myJson': json.dumps(data)}) ``` And in my template: ``` console.log('{{myJson}}'); ```

Original source