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>
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.