title: How do I add a header to a Django RequestFactory request?
body: <p>To manually send a GET request with a header, I do this with <code>curl</code>:</p>
  <pre><code>curl http://example.com/endpoint -H &quot;Key: Value&quot;
  </code></pre>
  <p>I want to write a unit test that makes a request (using <code>django.test.RequestFactory</code>) containing a header. How can I add a header to the request?</p>
  <p>For clarity, below is an example of what I'd <em>like</em> to be able to do, though what I have written below is <em>not</em> valid code because <code>RequestFactory.get()</code> does not have a <code>headers</code> parameter:</p>
  <pre><code>from django.test import TestCase, RequestFactory
  
  
  class TestClassForMyDjangoApp(TestCase):
      def test_for_my_app(self):
          factory = RequestFactory()
          
          my_header = dict(key=value, another_key=another_value)
          factory.get('/endpoint/', headers=my_header)
  </code></pre>