If I understand you correctly, you want to render some JSON in your HTML output.
To do this, pass the json-encoded object from the view to the template:
views.py:
import json def myview(request): obj = {"a": 1, "b": 2} return render_to_response("template.html", {"obj_as_json": json.dumps(obj)})
template.html:
<html> <head> <script type="text/javascript"> var obj = {{ obj_as_json|safe }}; </script> </head> ... </html>
Will render as:
... <script type="text/javascript"> var obj = {"a": 1, "b": 2}; ...
Note that json.dumps only works with dictionaries containing simple data types. Django has support for serializing model objects to json, using:
from django.core import serializers obj_as_json = serializers.serialize("json", my_model_object)
Update: note that you need to use "safe" to get this:
var obj = {"items": [{"human": "Genesis", "usfm": "GEN"},],}
instead of this:
var obj = {"items": [{"human": "Genesis", "usfm": "GEN"},],}