Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tkaemming/django-subdomains
base: f4eeb0184f
...
head fork: tkaemming/django-subdomains
compare: ca564ee11d
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 19, 2013
@cmsimike cmsimike Moved the logic to remove www from Site.domain into current_site_doma…
…in to fix issues reversing URLs when Site.domain has a www.
0a93c32
Commits on Feb 20, 2013
@tkaemming Merge pull request #19 from cmsimike/master
When using REMOVE_WWW_FROM_DOMAIN to remove www from Site.domain, reversing URLs in templates fails
ca564ee
Showing with 8 additions and 6 deletions.
  1. +0 −5 subdomains/middleware.py
  2. +8 −1 subdomains/utils.py
View
5 subdomains/middleware.py
@@ -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
9 subdomains/utils.py
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.