我一直在努力处理这件事,但我不知道怎么处理
我有一个表格,在那里我可以得到secs
form role="form" action="" method="POST" >{% csrf_token %}
<br>
<input type="number" name="secs" min="0" max="999" maxlength="3" class="form-control no-spinners" placeholder="Programar...">
<br>
<button type="submit" id="btn-login" class="w3-btn w3-large w3-green" style="width:30%"> Aceptar </button>
</form> 在我的views.py里
def streaming(request):
if request.method == 'POST':
secs = request.POST['secs']
print secs
programarTiempo(secs)
messages.info(request, 'Iniciando streaming en...' + secs + ' segundos')
time.sleep(float(secs))
return redirect('streaming')
return render(request, "straming.html", {"secs":secs})当我到达我的.html时,我得到了以下错误:
在赋值前引用的/ UnboundLocalError / local变量“secs”
,提前谢谢!
发布于 2017-07-17 22:00:06
问题是,如果方法不是Post,它将返回(最后一行),其中包含secs变量,但在if条件下定义了它
https://stackoverflow.com/questions/45154272
复制相似问题