The javascript code (highcharts) follows a similar syntax as pythons dict,
namely:
name: 'Female',
color: 'rgba(223, 83, 83, .5)',
data: [[161.2, 51.6], [163.8, 67.3]]
So I tried to directly use a python dict as a context, but got the
following result:
'color': 'rgba(223, 83, 83, .5)'
'name': 'Female'
The dict data makes it into the final html, but the quotes of the string
literals are respresented by '
It would be a great feature if the coupling from dict to template would
work. To make this more generic maybe some preprocessing function could be
defined that preps the dict data before it is pushed into the template.
--
Ticket URL: <https://code.djangoproject.com/ticket/20701>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0
Comment:
This is a duplicate of #17419 which cannot be implemented without
introducing major security problems (XSS). It's impossible to serialize an
arbitrary data structure into JavaScript embedded in HTML with Python's
`json` module with adequate escaping. Trust me, I tried hard.
Request the JSON blob with AJAX instead.
--
Ticket URL: <https://code.djangoproject.com/ticket/20701#comment:1>