request headers in django

Solutions on MaxInterview for request headers in django by the best coders in the world

showing results for - "request headers in django"
Léa
13 Apr 2020
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