Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango why i still got CSRF verification failed?
    primarykey
    data
    text
    <p>my template is below:</p> <pre><code> &lt;div id="divLogin"&gt; {% block login %} &lt;form action="/login" method="post"&gt; {% csrf_token %} &lt;label for="id_name"&gt;&lt;/label&gt;&lt;input type="text" name="email" id="id_name" placeholder="Your Email"&gt; &lt;label for="id_pass"&gt;&lt;/label&gt;&lt;input type="password" name="password" placeholder="Your Password"&gt; &lt;input type="submit" id="btnLogin" value="Log In" class="btn"&gt; &lt;/form&gt; {% endblock %} &lt;/div&gt; </code></pre> <p>I have already add {% csrf_token %} in template, and my login view is </p> <pre><code>def login_view(request): if request.method == 'POST': useremail=request.POST['email'] password=request.POST['password'] try: user=User.objects.get(email=useremail) if user.check_password(password): uAuth=authenticate(username=user.username,password=password) login(request,uAuth) return render_to_response("blog.html",{'loginuser':user},context_instance=RequestContext(request)) except User.DoesNotExist: return redirect('/') return redirect('/') </code></pre> <p>Even i used <code>render_to_response</code> and <code>RequestContext</code> i still got error. there is one thing very wired, i put a breakpoint to login_view method, but csrf error point out before it go into login_view methond. so there is no response about this method? </p> <p>Is there anything wrong about my code?</p> <p>I have add <code>django.middleware.csrf.CsrfViewMiddleware</code> in <code>MIDDLEWARE_CLASSES</code> in my settings.py.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload