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