如何使用Django获取主机服务器的名称? [英] How to use Django to get the name for the host server?
本文介绍了如何使用Django获取主机服务器的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Django获取主机服务器的名称?
How to use Django to get the name for the host server?
我需要托管服务器的名称而不是客户端名称?
I need the name of the hosting server instead of the client name?
推荐答案
我通常把这样的东西放在 settings.py
中:
I generally put something like this in settings.py
:
import socket
try:
HOSTNAME = socket.gethostname()
except:
HOSTNAME = 'localhost'
这篇关于如何使用Django获取主机服务器的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文