title: How to disable CSRF in Django 1.7?
body: <p>I am struggling to find a way to disable CSRF for a login view I am trying to implement. What's the best way to do it with Django 1.7? I am developing an Android application that is connecting to the /login url and sending a username and password, I have provided the code for the view below. I have tried to use @csrf_exempt on both the view and the url (in urls.py), but it doesn't work. The error I am getting is "CSRF verification failed. Request aborted". </p>
  
  <p>I have also tried to remove the middleware (django.middleware.csrf.CsrfViewMiddleware), but it doesn't work either.</p>
  
  <p>This is the code for the login view: </p>
  
  <pre><code>from django.views.decorators.csrf import csrf_exempt
  
  @csrf_exempt
  def login(request):
  
      fb_user_id = request.POST.get('username','')
      name = request.POST.get('name','')
      request.session['fb_user_id'] = fb_user_id
      create_user(fb_user_id, name)
      res = {}
      res["success"] = "yes"
      return HttpResponse(json.dumps(res))
  </code></pre>
  
  <p>Further, this is the url in urls.py: </p>
  
  <pre><code>url(r"^login/$", csrf_exempt(views.login), name='login'),
  </code></pre>
  
  <p>This is the response I am getting: </p>
  
  <p><img src="https://i.stack.imgur.com/KEppc.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/ZosSO.png" alt="enter image description here"></p>