title: Why do I get "CSRF cookie not set" when POST to Django REST framework?
body: <p>I am getting the error "CSRF cookie not set" returned when trying to POST to a simple test app using the Django REST framework. I've tried it with Django 1.4 and the Django 1.6.2. I am using the Django REST framework v 2.3.13. </p>
  
  <p>I have tried using the <code>@csrf_exempt</code> decorator, but it doesn't help.</p>
  
  <p>This is a very simple app, with no user registration / login etc.</p>
  
  <p>Any ideas why I'm getting this error?</p>
  
  <p><strong>Update: I have updated my urls.py as shown below and it is now working!!</strong></p>
  
  <p>Here's my code:</p>
  
  <p>urls.py</p>
  
  <pre><code>from django.conf.urls import patterns, url
  
  from quickstart import views
  
  urlpatterns = patterns('',
      url(r'^api_add/$', views.api_add, name='api_add'),
  )
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  
  @api_view(['POST'])
  def api_add(request):
      return Response({"test": 'abc'})
  </code></pre>
  
  <p>settings.py</p>
  
  <pre><code>INSTALLED_APPS = (
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.sites',
      'django.contrib.messages',
      'django.contrib.staticfiles',                                               
      'rest_framework',
  )
  </code></pre>
  
  <p>post.sh</p>
  
  <pre><code>curl -X POST -H "Content-Type: application/json" -d '
  {
      "name": "Manager",
      "description": "someone who manages"
  }' http://127.0.0.1:8000/api_add/                                               
  </code></pre>