我正在尝试登录django,但我收到此错误,我检查CSRF文档,没有任何对我有用.
这是HTML:
<body>
<section class="container">
<div class="login">
<h1>Login to Web App</h1>
{% if form.errors %}
<p class="error">Lo sentimos, la combinacion de usuario y contrasena no es correcta!</p>
{% endif %}
<form action="/accounts/auth/" method="post">
{% csrf_token %}
<input type='hidden' name='csrfmiddlewaretoken' value='randomchars'/>
<p><input name="username" type="text" name="login" value="" placeholder="Username"></p>
<p><input name="password" type="password" name="password" value="" placeholder="Password"></p>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
就像你在上面看到的那样,我使用{%csrf_token%}并且在我安装的应用程序中有'django.middleware.csrf.CsrfViewMiddleware'.
我的观点是:
from django.http import HttpResponse,HttpResponseRedirect
from django.template.loader import get_template
from django.template import Context
from datetime import datetime
from django.shortcuts …Run Code Online (Sandbox Code Playgroud)