获取Django网站的绝对网址

时间:2016-08-05 10:44:04

标签: python django

是否有可能以某种方式获取Django(分别为域名)的绝对URL?我的网站向管理员发送了电子邮件,我想在此电子邮件中添加一个链接,将其重定向到mysite/admin/some-tab

我已经阅读了类似问题的答案 - HERE,但我无法使用request因为它是在python脚本(notifications.py)中,不在templateviews.py

class AdminNotifications():
    @staticmethod
    def new_reservation(reservation):
        pass

    @staticmethod
    def new_pair(reservation1, reservation2):
        if reservation2.destination_to.is_airport:
            reservation1 , reservation2 = reservation2 , reservation1

        subject = u'Nový pár'

        message = u'Nový možný pár \n\nRezervácia 1: \n' \
                  u'ID rezervácie: {}\n' \
                  u'Zákazník: {}\n' \
                  u'Z: {}\n' \
                  u'Do: {}\n' \
                  u'Číslo letu: {}\n' \
                  u'Dátum odletu: {}\n' \
                  u'Čas odletu {}'.format(
            reservation1.id,
            reservation1.customer,
            reservation1.destination_from,
            reservation1.destination_to,
            reservation1.flight_number,
            reservation1.date_departure,
            reservation1.time_departure,

        ) + u'\n\nRezervácia 2: \n' \
                  u'ID rezervácie: {}\n' \
                  u'Zákazník: {}\n' \
                  u'Z: {}\n' \
                  u'Do: {}\n' \
                  u'Číslo letu: {}\n' \
                  u'Dátum príletu: {}\n' \
                  u'Čas príletu: {}'.format(
            reservation2.id,
            reservation2.customer,
            reservation2.destination_from,
            reservation2.destination_to,
            reservation2.flight_number,
            reservation2.date_arrival,
            reservation2.time_arrival,)+ \
                  u'\n\n\n\nRezervácie môžte upraviť tu: >> HERE I WANT TO PUT HREF TO MYSITE/ADMIN/SOME-TAB
        send_message_to_admin(subject,message)

0 个答案:

没有答案