社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  问与答

请教Django如何获取客户端【REMOTE_HOST】

mainzxq • 10 年前 • 4933 次点击  

公司使用的是AD域管理,每台PC都必须以域用户登陆。 我是一个Django初学者+菜鸟,请教各位大大一个问题:以前和同事一起搞过一个APACHE+PHP的网站,可以通过$_server取得远程客户端的域用户名。可是Django好像不可以,请教能有什么办法可以实现吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/737
 
4933 次点击  
文章 [ 1 ]  |  最新文章 10 年前
Py站长
Reply   •   1 楼
Py站长    10 年前

You can't rely on it, but you can try the request.META['REMOTE_HOST'] or request.META['HTTP_HOST'] from the META dictionary of the request :

A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server, but here are some examples:

- REMOTE_HOST -- The hostname of the client.
- HTTP_HOST -- The HTTP Host header sent by the client.

http://stackoverflow.com/questions/13093951/django-get-clients-domain-name-host-name