title: Why doesn't the csrf_exempt work on my view in Django?
body: <p>I am making a fetch request to one of the Urls as:</p>
  <pre><code>function like(id){
  
  
  fetch(`/likepost/${id}`, {
      method:'PUT',
      body: JSON.stringify({
          'id':id
      })
  })
  
  
  
  .then(response =&gt; response.json())
  .then(result =&gt; {
      console.log(result)
  })
  </code></pre>
  <p>and the url maps to this view:</p>
  <pre><code>path('likepost/&lt;int:post_id&gt;', views.likepost,name='like')
  </code></pre>
  <p>and the view is defined as:</p>
  <pre><code>@csrf_exempt
  def likepost(request, post_id):
      if request.method == 'PUT':
          data = json.loads(request.body)
          id = data.get('id')
          post = Post.objects.get(pk=id)    
          post.likes = post.likes+1
          post.save()
          return JsonResponse({'message':'liked succcessfuly'})
     else:
          return JsonResponse({'Message':'request should be post'})
  </code></pre>
  <p>but I am getting this error:</p>
  <pre><code>Forbidden (CSRF token missing or incorrect.): /likepost/12
  </code></pre>
  <p>even though I have used csrf_exempt, can anyone help me?</p>