1>>> request.headers
2{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6', ...}
3
4>>> 'User-Agent' in request.headers
5True
6>>> 'user-agent' in request.headers
7True
8
9>>> request.headers['User-Agent']
10Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
11>>> request.headers['user-agent']
12Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
13
14>>> request.headers.get('User-Agent')
15Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
16>>> request.headers.get('user-agent')
17Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
18
1def home_page(request):
2 # get the django.http.response.HttpResponse object
3 resp = render(request, 'dept_emp/home_page.html')
4 # set http response header and value.
5 resp['Cache-Control'] = 'public,max-age=100000'
6 resp['Vary'] = 'Accept-Encoding'
7 # return the HttpResponse object.
8 return resp