title: "detail": "CSRF Failed: CSRF token missing or incorrect."
body: <p>I'm making RESTful API using Tastypie, and when I try to <code>POST/PUT/DELETE</code> a request it says:</p>
  
  <blockquote>
    <p>"detail": "CSRF Failed: CSRF token missing or incorrect.".</p>
  </blockquote>
  
  <p>It works fine with <code>GET</code>. I've read various threads on SO, saying:</p>
  
  <ul>
  <li>to delete the cookies</li>
  <li>or use <code>@csrf_exempt</code></li>
  <li>or use <code>@method_decorator(csrf_exempt)</code></li>
  </ul>
  
  <p>but neither of it worked.</p>
  
  <p>How can I over-pass this error?</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class SnippetList(mixins.ListModelMixin,
                    mixins.CreateModelMixin,
                    generics.GenericAPIView):
      queryset = Snippet.objects.all()
      serializer_class = SnippetSerializer
  
      def get(self, request, *args, **kwargs):
          return self.list(request, *args, **kwargs)
  
  
      def post(self, request, *args, **kwargs):
          request._dont_enforce_csrf_checks = True
          print request.DATA
          return self.create(request, *args, **kwargs)
  </code></pre>
  
  <p><strong>serializer.py</strong></p>
  
  <pre><code>from django.forms import widgets
  from rest_framework import serializers
  from snippets.models import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES
  
  
  class SnippetSerializer(serializers.ModelSerializer):
      class Meta:
          model = Snippet
          fields = ('id', 'title', 'code', 'linenos', 'language', 'style')
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>from django.conf.urls import patterns, url
  from rest_framework.urlpatterns import format_suffix_patterns
  from snippets import views
  
  urlpatterns = patterns('',
      url(r'^snippets/$', views.SnippetList.as_view()),
      url(r'^snippets/(?P&lt;pk&gt;[0-9]+)/$', views.SnippetDetail.as_view()),
  )
  
  urlpatterns = format_suffix_patterns(urlpatterns)
  </code></pre>