Is it possible to somehow get an absolute url in Django (respectively domain name)? My site send's emails to admin and I want to put a link into this email to redirect him to mysite/admin/some-tab.
I've read answers on similar question - HERE, but I can't use request because it's in python script (notifications.py), not in template or views.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)
reservation1andreservation2from somewhere, can't you getrequestorURLfrom the same place?request.build_absolute_uri()from the view to the model then, as stackoverflow.com/a/7366386/1688590 passrequest.user.