From 2475b93e5f223deec0dc3fb3e8cbfba11f768280 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 4 Jul 2016 08:56:15 +0200 Subject: [PATCH] Use higher level functions to discover current host --- djangocms_multisite/middleware.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/djangocms_multisite/middleware.py b/djangocms_multisite/middleware.py index 61c48cd..763d109 100644 --- a/djangocms_multisite/middleware.py +++ b/djangocms_multisite/middleware.py @@ -10,11 +10,8 @@ from django.utils.six.moves import urllib_parse as urlparse class CMSMultiSiteMiddleware(object): def process_request(self, request): try: - full_host = '{scheme}://{host}'.format( - scheme=request.scheme, host=request.META['HTTP_HOST'] - ) - parsed = urlparse.urlparse(full_host) - host = parsed.hostname + parsed = urlparse.urlparse(request.build_absolute_uri()) + host = parsed.hostname.split(':')[0] urlconf = None try: urlconf = settings.MULTISITE_CMS_URLS[host]