[英]Adding CSRF protection to simple comment forms in Django
I have blog comment forms in Django and I would like to know the following: 我在Django中有博客评论表格,我想知道以下内容:
Each tutorial or discussion on the subject seems to have a different approach, and I am not certain I understand how it all works. 关于该主题的每个教程或讨论似乎都有不同的方法,并且我不确定我是否了解所有方法。
My answer assumes that you are using Django 1.2: 我的答案假设您使用的是Django 1.2:
render_comment_form
tag and you will see, that the csrf_token
is already included. render_comment_form
标记使用的默认模板,您会发现csrf_token
已经包含在内。 You can overwrite this template in your project and including the CSRF token into it is as easy as writing {% csrf_token %}
into the form. {% csrf_token %}
写入表单一样简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.