title: csrf error in django
body: <p>I want to realize a login for my site. I basically copied and pasted the following bits from the Django Book together. However I still get an error (CSRF verification failed. Request aborted.), when submitting my registration form. Can somebody tell my what raised this error and how to fix it?</p>
  
  <p>Here is my code:</p>
  
  <p>views.py:</p>
  
  <pre><code># Create your views here.
  from django import forms
  from django.contrib.auth.forms import UserCreationForm
  from django.http import HttpResponseRedirect
  from django.shortcuts import render_to_response
  
  def register(request):
      if request.method == 'POST':
          form = UserCreationForm(request.POST)
          if form.is_valid():
              new_user = form.save()
              return HttpResponseRedirect("/books/")
      else:
          form = UserCreationForm()
      return render_to_response("registration/register.html", {
          'form': form,
      })
  </code></pre>
  
  <p>register.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  {% block title %}Create an account{% endblock %}
  
  {% block content %}
    &lt;h1&gt;Create an account&lt;/h1&gt;
  
    &lt;form action="" method="post"&gt;{% csrf_token %}
        {{ form.as_p }}
        &lt;input type="submit" value="Create the account"&gt;
    &lt;/form&gt;
  {% endblock %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>