title: Django: Forbidden (CSRF cookie not set.), Why this is happening , and How to fix it
body: <p>I wrote a test file to check if the URL works or not and it keeps printing Forbidden (CSRF cookie not set.) could please check what's the problem</p>
  
  <pre class="lang-py prettyprint-override"><code>#post handler
  @csrf_exempt
      def post(self, request, *args, **kwargs):
          valid_json = is_json(request.body)
          if not valid_json:
              error_data = json.dumps({'message': 'Invalid data sent, please send using JSON format'})
              return self.render_to_response(error_data, status=400)
          data = json.loads(request.body)
          form = SupervisorForm(data)
          if form.is_valid():
              obj = form.save(commit=True)
              obj_data = obj.serialize()
              return self.render_to_response(obj_data, status=201)
          if form.errors:
              data_error = json.dumps(form.errors)
              return self.render_to_response(data_error, status=400)
          json_data = json.dumps({'message': 'Not Allowed'})
          status_code = HTTP_400_BAD_REQUEST
          return self.render_to_response(json_data, status_code)
  
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>
  def post():
      data = {
          'supervisor_name':'name',
          'supervisor_phone': '76786875',
          'supervisor_email': 'sdsds@sdsd.com',
          'supervisor_image': 'path to local image',
      }
      json_data = json.dumps(data)
      json_loads = json.loads(json_data)
      print(type(json_data))
      print(type(json_loads))
      print(help(requests.put))
      r = requests.put('http://127.0.0.1:8000/api', json = json.dumps(data))
  
      return r.json()
  </code></pre>