title: Django: CSRF cookie not set
body: <p>I want to post a form in my django project resulting in a "CSRF cookie not set." error.</p>
  
  <h2>views.py</h2>
  
  <pre><code>from django.shortcuts import render
  from django.template import RequestContext
  from pyBikeMilesApp.models import Eintrag
  from django.template.context_processors import csrf
  
  # Create your views here.
  def index(request):
    if request.method == 'POST':
      print(request.POST)
  
    # Get all posts from DB
    eintraege = Eintrag.objects
    return render(request,'index.html',{'Eintraege': eintraege})
  </code></pre>
  
  <h2>index.html</h2>
  
  <pre><code>{% extends 'base.html' %}
  
  {% block title %}BikeMiles{% endblock %}
  
  {% block content %}
  &lt;div class="col-md-12"&gt;
    &lt;table class="table table-striped"&gt;
      &lt;tr&gt;
        &lt;th&gt;gefahrene KM&lt;/th&gt;
        &lt;th&gt;Datum&lt;/th&gt;
        &lt;th&gt;Kommentar&lt;/th&gt;
        &lt;th&gt;Aktion&lt;/th&gt;
        {% for eintrag in Eintraege %}
        &lt;tr&gt;
          &lt;td&gt;{{ eintrag.kommentar }}&lt;/td&gt;
          &lt;form method="post" action="http://127.0.0.1:8000/"&gt;
             {% csrf_token %}
            &lt;input type="hidden" name="id" value="{{eintrag.id}}"&gt;
            &lt;input type="submit" class="btn btn-xs btn-danger" value="delete" &gt;
          &lt;/form&gt;
        &lt;/tr&gt;
        {% endfor %}
      &lt;/table&gt;
    &lt;/div&gt;
    {% endblock %}
  </code></pre>
  
  <p>in the generated page i can see the csrf input field:</p>
  
  <pre><code>&lt;input type='hidden' name='csrfmiddlewaretoken' value='zzRnENjz6wrUP8Op8IVOIDsUVvclY37k' /&gt;
  </code></pre>
  
  <p>Any idea, how to fix that? </p>