【发布时间】:2014-05-04 08:44:00
【问题描述】:
我的应用程序将托管在多个域中,我需要一个 django 视图功能中的域名...如何实现?我正在使用 django 1.3.3。
我想要这样的东西
www.syz.com 127.0.0.1:8000
【问题讨论】:
我的应用程序将托管在多个域中,我需要一个 django 视图功能中的域名...如何实现?我正在使用 django 1.3.3。
我想要这样的东西
www.syz.com 127.0.0.1:8000
【问题讨论】:
看看request.get_host()
文档:https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_host
或在您的模板中(如果您使用 requestContext){{request.get_host}}
正如@jayanth-koushik 提到的,您可以在这里找到更多信息:How can I get the domain name of my site within a Django template?
【讨论】: