views:

50

answers:

1

When the page loads, I have a JavaScript function that needs to analyze the JSON. But, this JSON must be present when I load "something.html"

I know how to do this, but I don't know how to combine them together.

return HttpResponse(thejson, mimetype="application/javascript")
+3  A: 

If you want the json to be in your template from the start, just pass it in like any other variable:

return render_to_response('something.html', {'json':thejson, 'othervariable':foo})
Daniel Roseman
Then, how would I include it? LIke this? {{thejson}}
TIMEX
In my example, `{{ json }}`, because I called the dictionary key (the bit in quotes) `'json'`.
Daniel Roseman