#20701: Using python dicts directly in javascript
----------------------------------+--------------------
Reporter: tim0306+django@… | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
I'm using Django to push some data from python into some javascript code.
So I use RequestContext to set up the variables and hen use HttpResponse
to render the template with the variables.
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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.771ec95ac6f17b9bd5a1182e72058376%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.