Permalink
Browse files

Merge pull request #19 from cmsimike/master

When using REMOVE_WWW_FROM_DOMAIN to remove www from Site.domain, reversing URLs in templates fails
  • Loading branch information...
2 parents f4eeb01 + 0a93c32 commit ca564ee11d59391bf9613c1ba45dff2fd8190cbf @tkaemming committed Feb 20, 2013
Showing with 8 additions and 6 deletions.
  1. +0 −5 subdomains/middleware.py
  2. +8 −1 subdomains/utils.py
View
@@ -32,11 +32,6 @@ def process_request(self, request):
domain, host = map(lower,
(self.get_domain_for_request(request), request.get_host()))
- prefix = 'www.'
- if getattr(settings, 'REMOVE_WWW_FROM_DOMAIN', False) \
- and domain.startswith(prefix):
- domain = domain.replace(prefix, '', 1)
-
pattern = r'^(?:(?P<subdomain>.*?)\.)?%s(?::.*)?$' % re.escape(domain)
matches = re.match(pattern, host)
View
@@ -7,7 +7,14 @@
def current_site_domain():
- return Site.objects.get_current().domain
+ domain = Site.objects.get_current().domain
+
+ prefix = 'www.'
+ if getattr(settings, 'REMOVE_WWW_FROM_DOMAIN', False) \
+ and domain.startswith(prefix):
+ domain = domain.replace(prefix, '', 1)
+
+ return domain
get_domain = current_site_domain

0 comments on commit ca564ee

Please sign in to comment.