[Answered ]-{{ request.META.HTTP_HOST }} not supported in Djagno 1.6.4? Easy way to get the host URL?

1👍

Use request.get_host():

Returns the originating host of the request using information from the
HTTP_X_FORWARDED_HOST (if USE_X_FORWARDED_HOST is enabled) and
HTTP_HOST headers, in that order.

👤alecxe

1👍

The get_host() method fails when the host is behind multiple proxies. One solution is to use middleware to rewrite the proxy headers, as in the following example https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.get_host

Leave a comment