Use higher level functions to discover current host

This commit is contained in:
Iacopo Spalletti 2016-07-04 08:56:15 +02:00
parent 1283d3139c
commit 2475b93e5f
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6

View file

@ -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]