# In mypage.html
<form method='get' action=''>
<input type="submit" value="add" name="add"/>
</form>
<h1>{{ p }}</h1>
# In the views.py file
p = 1
def mypage(request):
global p
my_dictionary = {
"p" : p,
}
if request.GET.get('add'):
p = p+1
if 'p' in request.session:
request.session['p'] = request.session['p'] + 1
else:
request.session['p'] = 1
my_dictionary = {
"p" : p,
}
return render(request, "mypage.html", my_dictionary)
mypage.html
essentially adds 1 to p when the button "add"
is clicked. However I want the add to reset back to p=1
when the page is refreshed. How would I do that?
Thanks.