我试图获得存储在变量中的值:
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})
我该怎么做呢?我根据要求尝试了不同的版本。Get ['no'] too, but nothing worked,如果有人有一个想法,谢谢你的帮助
您可以创建一个链接到特定视图的标记,并将值'no'传递给该视图。观点:
def nextep(request, value):
n = value
return render(request, "episode.html", {'no': value+1})
HTML:
<a href={%url 'nextep' {{no}}%}>Next Step </a>