Python 不工作{%csrf_令牌%}

Python 不工作{%csrf_令牌%},python,django,csrf,Python,Django,Csrf,Django 1.9.5 CSRF令牌未添加隐藏表单字段。尝试使用RequestContext渲染到请求,只是渲染,尝试装饰-没有效果,隐藏的输入不显示 home.html <script> $(document).ready(function() { $("#encrypt").click(function () { var postData = { text: $("#input-box").val(), r

Django 1.9.5 CSRF令牌未添加隐藏表单字段。尝试使用RequestContext渲染到请求,只是渲染,尝试装饰-没有效果,隐藏的输入不显示

home.html

<script>
$(document).ready(function() {
    $("#encrypt").click(function () {
        var postData = {
            text: $("#input-box").val(),
            rotate: $("#rotate").val()
        };
        $.post('/encrypt', postData, function (out){
            alert(out)
        });
    });
});
  </script>
<form name="ciepher" method="POST" action="">
          {% csrf_token %}
 <!-- form code-->
</form>
你不能和我一起通过。将代码修改为类似以下内容:

def home(request):
    return render_to_response("home.html", context_instance=RequestContext(request))
或者您也可以使用快捷方式:

def home(request):
    return render(request, "home.html")

哦,这么容易犯的错误,花了这么多时间。非常感谢,它的工作!一定要使用
渲染
快捷方式
def home(request):
    return render(request, "home.html")