title: Set headers for AJAX request to Django
body: <p>I want to test some AJAX requests to my Django site, but the server doesn't think the request from my test tool is an AJAX request. What HTTP header do I need to set?</p>
  
  <p>The server code has a test like this:</p>
  
  <pre><code># in myapp/ajax.py
  def my_request(request, some_id):
      if request.is_ajax():
          return json.dumps([some_id, 'processed for AJAX'])
  
      # some other processing, or an error
  </code></pre>
  
  <p>I'm using <a href="https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en" rel="nofollow">Postman</a> to send my AJAX request, and I've learned to set the <code>Accept</code> header to <code>application/json</code>, but what header do I set to show that it's an AJAX request?</p>
  
  <p>In the Django code, I found the test method:</p>
  
  <pre><code>def is_ajax(self):
      return self.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
  </code></pre>
  
  <p>When I set the <code>HTTP_X_REQUESTED_WITH</code> header to <code>XMLHttpRequest</code>, the test still fails.</p>