'For a given request domain, find a match in our microsite configuration
and then assign it to the thread local in order to make it available
to the complete Django request processing'

def set_config_by_domain(self, domain):

    if ((not self.has_configuration_set()) or (not domain)):
        return
    for (key, value) in settings.MICROSITE_CONFIGURATION.items():
        subdomain = value.get('domain_prefix')
        if (subdomain and domain.startswith(subdomain)):
            self._set_microsite_config(key, subdomain, domain)
            return
    if ('default' in settings.MICROSITE_CONFIGURATION):
        self._set_microsite_config('default', subdomain, domain)
        return
