[Answered ]-Send model field value to javascript variable

2👍

The easiest way is to add it to whatever template you are using like so:

<script>
   var my_javascript_var = "{{ my_model.my_attribute }}";
</script>

However this requires setting my_model (or some other variable) in the context for your template when it is rendered.

Leave a comment