Jul-15-2023, 02:17 PM
In a django project, i have the function below. I am trying to increment the toGoFor variable each time the button is pressed.
I have the following code.
Quite new to Django so any help be greatly appreciated.
I have the following code.
def rtb(request): if request.method == 'POST': toGoFor += 1 dict = { "toGoFor" : toGoFor} return render(request, 'rtb.html', dict) else: toGoFor = 1 dict = { "toGoFor" : toGoFor} return render(request, 'rtb.html', dict)When it is run the first time it is called as a Get it works, but when the button is pressed I get the following error.
Quote:local variable 'toGoFor' referenced before assignment
Quite new to Django so any help be greatly appreciated.