Django的:{%csrf_token%}保持返回403 Forbidden错误

问题描述 投票:0回答:1

我有我尝试但是提交表单每当我点击提交按钮Django的使我进入403禁止页错误。我不知道如何解决这个问题。请帮忙。这是使用CSS物化完成。

page.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>

views.朋友:

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')
python django django-csrf
1个回答
-1
投票

它会工作,只是刷新页面或关闭标签不是尝试。

© www.soinside.com 2019 - 2024. All rights reserved.