Possible Duplicate:
Django: Parse JSON in my template using Javascript
I'm trying to pass a Python data structure to javascript via a GAE/Django template and following the steps here. I'm getting an error that I can't figure out.
Here is the relevant excerpt of my Python GAE code:
class MyRequestHandler(webapp.RequestHandler):
template_values = dict(
data = json.dumps(dict(hello = "world"))
)
path = os.path.join(TPATH, 'template.html')
self.response.out.write(template.render(path, template_values))
Here is the relevant excerpt from the Django template:
<script type="text/javascript">
var data = {{ data }};
</script>
This gives the error:
Invalid property id
var data = {"hello": "world"};
Can you help me figure out what I am doing wrong?
EDIT:
As noted this is a duplicate and the fix is to do this.
<script type="text/javascript">
var data = {{ data|safe }};
</script>