javascript variable to django template

41 views
Skip to first unread message

kml Awad

unread,
Nov 15, 2016, 12:53:56 PM11/15/16
to Django users
Hi,

How can I inject javacript object (variable ) in django template (html) ?

Thank you for your help.

regards.

GMail

unread,
Nov 15, 2016, 12:58:57 PM11/15/16
to django...@googlegroups.com
Hi,

As any other variable:

<script>
  var myAwesomeVar = {{ my_awesome_var }};
  alert(myAwesomeVar);
</script>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/57cc4f22-3aad-4b2a-8a21-4f0fe957cc0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages