Django:{%csrf\u token%}继续返回403禁止

2024-04-27 22:13:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个表格,我试图提交,但每当我点击提交按钮Django把我放入403禁止页错误。我不知道怎么解决这个问题。请帮忙。这是使用物化CSS完成的。你知道吗

你知道吗页面.html地址:

<form action="/present/" method="POST">
    {% csrf_token %} 
    <p>
        <input type="checkbox" id="completed" name="completed" />  
        <label for="completed">Present</label>
    </p>
        <input class="waves-effect waves-light btn" type='submit'/>

</form>

你知道吗视图.py地址:

def present(request):
    completed = request.GET.get('pre')
    if request.POST.get('completed', '') == 'on':
        print("Succes!")
    else:
        print("Nope")
    #above coode doesn't work either for detecting whether or not the 
checkbox was selected.
    return render(request, 'main/test.html')

Tags: formforinputgetrequest地址htmltype