Nishant Nawarkhede
Nishant Nawarkhede

Reputation: 8400

assign javascript variable to django template variable

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>

Upvotes: 0

Views: 557

Answers (1)

lanzz
lanzz

Reputation: 43168

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.

Upvotes: 3

Related Questions