title: Django REST Framework Forbidden CSRF cookie not set
body: <p>I have this view</p>
  
  <pre><code>from rest_framework import parsers, renderers
  from rest_framework.authtoken.models import Token
  from rest_framework.authtoken.serializers import AuthTokenSerializer
  from rest_framework.response import Response
  from rest_framework.views import APIView
  from .serializers import EmailUserSerializer
  from django.utils.decorators import method_decorator
  from django.views.decorators.csrf import csrf_exempt
  
  
  @method_decorator(csrf_exempt, name='post')
  class ObtainAuthToken(APIView):
      throttle_classes = ()
      permission_classes = ()
      parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
      renderer_classes = (renderers.JSONRenderer,)
      serializer_class = AuthTokenSerializer
  
      def post(self, request, *args, **kwargs):
          serializer = self.serializer_class(data=request.data)
          serializer.is_valid(raise_exception=True)
          user = serializer.validated_data['user']
          token, created = Token.objects.get_or_create(user=user)
          user_serializer = EmailUserSerializer(user)
          return Response({'token': token.key, 'user': user_serializer.data})
  
  
  obtain_auth_token = ObtainAuthToken.as_view()
  </code></pre>
  
  <p>and this url</p>
  
  <pre><code>urlpatterns = [
      url(r'^login/$',views.obtain_auth_token, name='get_auth_token'),
      url(r'^login2/$',ObtainAuthToken, name='get_auth_token'),
  ]
  </code></pre>
  
  <p>i'm trying posting with postman like this:</p>
  
  <pre><code>127.0.0.1:8000/api/login2/
  </code></pre>
  
  <p>but i can only receive this error </p>
  
  <pre><code>Forbidden (CSRF cookie not set.): /api/login2/
  [02/Jul/2017 22:49:11] "POST /api/login2/ HTTP/1.1" 403 2891
  </code></pre>
  
  <p>I know there are hundreds of post like this, I searched for a long time a solution but nothing seems working</p>
  
  <p>tryied like this</p>
  
  <pre><code>urlpatterns = patterns('',
      url('^login2/$', csrf_exempt(ObtainAuthToken)),
      ...
  )
  </code></pre>
  
  <p>this</p>
  
  <pre><code>from django.utils.decorators import method_decorator
  class LoginView(APIView):
     @method_decorator(csfr_exempt)
     def dispatch(self, *args, **kwargs):
         ...
  </code></pre>
  
  <p>and also this</p>
  
  <pre><code>from django.utils.decorators import method_decorator
  
  @method_decorator(csrf_exempt, name='dispatch')
  class LoginView(APIView):
         ...
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>@method_decorator(csrf_exempt, name='post')
  class ObtainAuthToken(APIView):
      throttle_classes = ()
      ...
      @csrf_exempt
      def post(self, request, *args, **kwargs):
          serializer = self.serializer_class(data=request.data)
  </code></pre>