title: CSRF verification failed - Request aborted
body: <p>I am getting the CSRF failure in Django and no articles are working.
  It says it's used for posts like I remember, and it is included in the form, but not in a form tag.</p>
  <p>settings.py</p>
  <pre><code>MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  </code></pre>
  <p>login.html</p>
  <pre><code>{% extends 'base.html' %}
  {% block body_block %}
  
  &lt;h1&gt;Login&lt;/h1&gt;
  
  &lt;form id=&quot;login_form&quot; method=&quot;post&quot; action=&quot;{% url 'accounts:login' %}&quot;&gt;
      {% csrf_token %}
      &lt;div class=&quot;input-group input-group-md&quot;&gt;
          &lt;span class=&quot;input-group-addon&quot;&gt;Username&lt;/span&gt;
          &lt;input type=&quot;text&quot;class=&quot;form-control&quot; placeholder=&quot;Username&quot; aria-describedby=&quot;basic-addon2&quot; name=&quot;username&quot; value=&quot;&quot; size=&quot;50&quot; /&gt;
      &lt;/div&gt;
      &lt;br&gt;
      &lt;div class=&quot;input-group input-group-md&quot;&gt;
          &lt;span class=&quot;input-group-addon&quot;&gt;Password&lt;/span&gt;
          &lt;input class=&quot;form-control&quot; placeholder=&quot;Password&quot; aria-describedby=&quot;basic-addon2&quot; type=&quot;password&quot; name=&quot;password&quot; value=&quot;&quot; size=&quot;50&quot; /&gt;
      &lt;/div&gt;
       &lt;br&gt;
      &lt;div class=&quot;input-group input-group-md&quot;&gt;
          &lt;input class=&quot;btn btn-default navbar-btn&quot; type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;a style=&quot;font-size:22px;&quot; href=&quot;/accounts/register/&quot;&gt;Need to make a new account?&lt;/a&gt;
  
  
  {% endblock %}
  
  {% block buttons %}
  {% endblock %}
  </code></pre>
  <p>views.py:</p>
  <pre><code>def user_login(request):
      context = RequestContext(request)
      if request.method == 'POST':
          form = LoginForm(request.POST)
          username = request.POST['username']
          password = request.POST['password']
  
          user = authenticate(username=username, password=password)
  
          if user:
              if user.is_active:
                  login(request, user)
                  return redirect('bookmarks:silo')
              else:
                  return HttpResponse(&quot;Your Sitename account is disabled.&quot;)
  
          else:
              return render_to_response('accounts/login.html', locals(), context)
      else:
  
          template_name = 'accounts/login.html'
          return render_to_response('accounts/login.html', locals(), context)
  </code></pre>
  <p>Why is this csrf token not working?</p>