Merge pull request #10 from nephila/feature/use_get_host

Use higher level functions to discover current host
This commit is contained in:
Iacopo Spalletti 2016-07-04 08:59:43 +02:00 committed by GitHub
commit 35397dd4ff

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]