-2

I want to access a javascript variable in my views.py of a Django project

3
  • You cant. But you can use ajax call to send value to django. Commented Mar 2, 2020 at 12:29
  • Go and look at this - stackoverflow.com/questions/34147248/… Commented Mar 2, 2020 at 12:30
  • 2
    you can not access javascritpt variable in python. because JavaScript used at frontend-side. and python(DJANGO) used at backend-side. Commented Mar 2, 2020 at 12:42

1 Answer 1

1

If the variable is created in your template, you can't. You can only pass data from your views.py into your template not the other way around.

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.