I have the following code in one of my templates.
<html>
<body>
<script>
var val1 = 10;
var val2 = 20;
</script>
<a href="/generate/">Generate</a>
</body>
</html>
I wish to use the values val1 and val2 in the generate function in the views.py file. It would be something like this.
def generate(request):
# do something with val1 and val2
I am lost as to how I can pass these values to the function. What is the best practice for this, should I try to retrieve the information through URL parameters? Or perhaps I should just remove the Javascript and do everything in Python directly in the generate() function?
Thank you for your help!