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): class CMSMultiSiteMiddleware(object):
def process_request(self, request): def process_request(self, request):
try: try:
full_host = '{scheme}://{host}'.format( parsed = urlparse.urlparse(request.build_absolute_uri())
scheme=request.scheme, host=request.META['HTTP_HOST'] host = parsed.hostname.split(':')[0]
)
parsed = urlparse.urlparse(full_host)
host = parsed.hostname
urlconf = None urlconf = None
try: try:
urlconf = settings.MULTISITE_CMS_URLS[host] urlconf = settings.MULTISITE_CMS_URLS[host]