I'm using django templates to create an e-mail. I do something like this:
msg_html = render_to_string('email/%s.html' % template_name, context)
msg = EmailMultiAlternatives(subject, msg_text, from_email, to_list)
msg.attach_alternative(msg_html, "text/html")
msg.content_subtype = "html"
msg.send()
My template uses named url patterns like so: {% url url_name parameter %}
Which works fine, except it will render a relative url, like: /app_name/url_node/parameter
Usually that is enough, but since this is an e-mail I really need it to be a full url - with the server name prepended, like: http://localhost:8000/app_name/url_node/parameter.
How can I do this? How do I dynamically get the server name? (I don't want to hardcode it for sure).
Another way of asking: how do I get HttpServletRequest.getContextPath() ala Java, but instead in Django/Python?
thanks