获取用户的相关请求信息, 以及包括请求头 request.environ

#在index文件中
1.
print(type(request))
#看出所属库
2. 
from django.core.handlers.wsgi import  WSGIRequest
#查看WSGIRequest
发现主要的输入参数是environ
3.
print(request.environ)
#发现其是字典
4. 循环 request.environ 

5.我们要找的请求头是HTTP_USER_AGENT

print(request.environ['HTTP_USER_AGENT'])
原文地址:https://www.cnblogs.com/my-love-is-python/p/9459468.html