title: Django custom response headers
body: <p>I need to set custom response headers in Django project.</p>
  
  <p>Here is code from facts/urls.py:</p>
  
  <pre><code>d = {
      'app_name': 'facts',
      'model_name': 'Fact'
  }
  
  urlpatterns = patterns('',
      (r'^$', 'facts.main', d),
  )
  </code></pre>
  
  <p>This approach shows data from model, but I'am not sure if there is a way to set custom headers here?</p>
  
  <p>Also I tried another approach - I created facts/views.py with following function:</p>
  
  <pre><code>def fact(request):
  
      response = render_to_response('facts.html', 
                                    {'app_name': 'facts',
                                     'model_name': 'Fact'}, 
                                    context_instance=RequestContext(request))
  
      response['TestCustomHeader'] = 'test'
  
      return response
  </code></pre>
  
  <p>and changed code in urls.py:</p>
  
  <pre><code>(r'^$', facts.views.fact),
  </code></pre>
  
  <p>This approach sets custom headers but doesn't show data from model. </p>
  
  <p>Any help?</p>