Best practice to move template variables to JS variables

This is what I am currently doing to transfer a django template variable to a JS variable:

<input type="hidden" id="django_var" value="{{variable}}" />
...
var unique_var = $  ('#django_var').val();

Is there a more straightforward way to do this in the template, something that would work outside of forms as well? Thank you.

newest questions tagged jquery – Stack Overflow

About Admin