Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have passed a variable(list of dictionary) to template in django. I need that variable in java script. How can I get the variable as list without using json.dumps in django views.
json.dumps
If you have a dictionary in django say myObj, you may simply put this kind of dynamic javascript substitution to use that in javascript
myObj
<script type="text/javascript"> var obj = "{{myObj}}" </script>
Cheers!
Add a comment
JSON.parse(obj)
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.