Reputation: 93
I am trying to get the value which is stored in a variable as :
html
<p class="title" name="no">Guarde : {{no}}</p>
...
<form action="nextep" method="get">
<button class="btright" name="btnext" action="nextep">
<i class="fas fa-chevron-circle-right"></i>
</form>
views.py
def nextep(request):
n = {{ no }} #I would like to get it from the initial value stored (which is 1)
return render(request, "episode.html", {'no': n+1})
How could I do that please? I tried different version with request.get['no'] too, but nothing worked, if someone has an idea, thanks for you help
Upvotes: 0
Views: 195
Reputation: 205
You can create a tag to link to a particular view and pass the value of 'no' to the view. View:
def nextep(request, value):
n = value
return render(request, "episode.html", {'no': value+1})
HTML:
<a href={%url 'nextep' {{no}}%}>Next Step </a>
Upvotes: 1