surresh kummar
surresh kummar

Reputation: 15

How to use use a django variable in html <script> tag?

Like the python variable has a list of values and I want to equate a variable, say var list= python variable inside tag.

Upvotes: 1

Views: 2367

Answers (1)

sjakur
sjakur

Reputation: 26

Variable tags in Django are surrounded by {{ and }}and they're replaced with values when the template is evaluated. That being said, you can make use of the Django variables in JavaScript as follow:

<script type="text/javascript"> 
   var list = "{{djangoVariable}}"
</script>

Upvotes: 1

Related Questions