Server Setup - Linux-CentOS7, Apache2.4, MySQL, Python3.6.8, Django2.2
-
Client OS - Windows10, Windows7, CentOS, MacOS ...
Client Computer Hostname = MyPC_011
Client Computer logged in username = user-A
在视图.py我想使用客户端机器登录用户名(user-A)当用户访问django网站页面。在
这是我的视图.py在def home_view(request):
# Get IP address of client computer
client_ip = request.META.get('REMOTE_ADDR')
# Get Host Name of client computer
client_host = request.META.get('REMOTE_HOST')
return render(request, 'index.html')
我通过远程地址获取IP地址,远程主机为空,用户和用户名显示服务器用户名。在'GATEWAY_INTERFACE': 'CGI/1.1', 'SERVER_PORT': '8000', 'REMOTE_HOST': '', 'CONTENT_LENGTH': '', 'SCRIPT_NAME': '', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.2', 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/', 'QUERY_STRING': '', 'REMOTE_ADDR': '192.168.5.107', '
当用户访问django网站页面时,如何获得客户端登录用户名?在