Is there is any way to assign javascript
variable to django template variable
?
In short can i do like this ?
<script>
var x=10;
{{somedvar}}=x;
</script>
asked Apr 7, 2014 at 7:32
-
Can you please how you solved this, im in the same situation.Kevin– Kevin2015年05月07日 08:53:04 +00:00Commented May 7, 2015 at 8:53
-
@Kevin can you please brief me about the situation you are facing ?Nishant Nawarkhede– Nishant Nawarkhede2015年05月14日 17:07:22 +00:00Commented May 14, 2015 at 17:07
1 Answer 1
Javascript is executed in your visitors' browsers after Django has already finished responding to the request. So no, it is not possible, and it actually doesn't make sense. Besides plain Django does not support assignment to variables within templates at all, so it is a bit far-fetched to expect that it would support it in this very specific case.
answered Apr 7, 2014 at 7:38
Comments
lang-py