开发者

Django: get the current domain(http_host) from signals

开发者 https://www.devze.com 2023-02-23 06:39 出处:网络
I am sending a mail with different confirmation links from different signals. These mails contain a link that the recipient has to click. If I am sending the link from www.example.com the confirmation

I am sending a mail with different confirmation links from different signals. These mails contain a link that the recipient has to click. If I am sending the link from www.example.com the confirmation link looks something like www.example.com/confirmation.

At the moment I am hard coding the开发者_如何学Go domain name inside my settings file but maybe there is a better way more flexible way?


Use standard sites contrib app


if you don't want to use the site framework just to get domain name you can use the get_host function with request object. domain_name = request.get_host() but remember that this function return also the port use when requesting the page, So you can have domain.com:8000 for example

0

精彩评论

暂无评论...
验证码 换一张
取 消