Created
September 11, 2012 02:35
-
-
Save hersonls/3695520 to your computer and use it in GitHub Desktop.
Middleware for django-subdomains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubdomainURLRoutingMiddleware(SubdomainMiddleware): | |
def process_request(self, request): | |
super(SubdomainURLRoutingMiddleware, self).process_request(request) | |
subdomain = getattr(request, 'subdomain', False) | |
if subdomain is not False and subdomain not in settings.SUBDOMAIN_BLACKLIST: | |
# Here is the trick. I will put at the first rule the users url | |
# set at the settings, this way, the first page will be the | |
# user page matched with subdomain. | |
request.urlconf = settings.SUBDOMAIN_URL_ROUTER | |
# Continue processing the request as normal. | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment