title: How to use Django's @csrf_exempt decorator to enable an API to do PUT?
body: <p>I'm building a Django application with Django-Rest-Framework APIs. I have built an API endpoint as shown below. </p>
  
  <p>I want to be able to POST data from my browser. I want this POST operation to retrieve an object model from my Database that has the matching primary key as given in the URL. And I want to modify that retrieved object based on the data posted by the browser. </p>
  
  <p>If I could just grab the posted data from with my ViewSet, I would be done. But when I try to execute that viewset's update() function, I get a CSRF error.</p>
  
  <p>From my urls.py file:</p>
  
  <pre><code>router.register(r'replyComment', views.ReplyComment, base_name="replyComment")
  </code></pre>
  
  <p>From my views.py file:</p>
  
  <pre><code>class ReplyComment(viewsets.ViewSet):
      def update(self,request,pk=None):
          try: 
              origComment = Comment.objects.get(pk=pk)
              # Do something here that modifies the state of origComment and saves it.
              return Response(
                  json.dumps(True), 
                  status=status.HTTP_200_OK,
              )
          except Exception as exception:
              logger.error(exception)
              return Response(status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>I'm using the Advanced Rest Client (ARC) tool in my Chrome browser. When I point the ARC tool to <code>http://127.0.0.1:3001/api/replyComment/2/</code> using the POST method, I get the following error: </p>
  
  <pre><code>{
      detail: "CSRF Failed: CSRF token missing or incorrect". 
  }
  </code></pre>
  
  <p><a href="https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax" rel="nofollow"><strong>This doc</strong></a> indicates that I should use the <code>@csrf_exempt</code> decorator. I put that decorator on my update() function above. But it seemed to make no difference.</p>
  
  <p>What changes do I need to make to ensure my POST works as I intend it to?</p>