0

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
2
  • Can you please how you solved this, im in the same situation. Commented May 7, 2015 at 8:53
  • @Kevin can you please brief me about the situation you are facing ? Commented May 14, 2015 at 17:07

1 Answer 1

3

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.