2
我的應用程序將在多個域中進行託管,我需要在django視圖函數中使用域名...如何實現此目的?我正在使用django 1.3.3。如何在django視圖函數中獲取域名?
我想是這樣的
www.syz.com 127.0.0.1:8000
我的應用程序將在多個域中進行託管,我需要在django視圖函數中使用域名...如何實現此目的?我正在使用django 1.3.3。如何在django視圖函數中獲取域名?
我想是這樣的
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}}
as @ jayanth-koushik提到它,你可以在這裏找到更多:How can I get the domain name of my site within a Django template?