python django CSRFverificationfailed.Requestaborted
上一篇 /
下一篇 2016-12-08 14:29:19
/ 个人分类:python
Django 针对 CSRF 的保护措施是在生成的每个表单中放置一个自动生成的令牌,通过这个令牌判断 POST 请求是否来自同一个网站。
首次使用到 Django 的模板,使用“模板标签”( templatetag) 添加 CSRF 令牌。在 from 表单中添加{% csrf_token %}。
<form. method="post">
<input name="username" type="text" placeholder="username" ><br>
<input name="password" type="password" placeholder="password"><br>
<button id="btn" type="submit">登录</button>
{% csrf_token %}
</form>
收藏
举报
TAG: