diff --git a/subdomains/templatetags/subdomainurls.py b/subdomains/templatetags/subdomainurls.py index a73a866..d9025ec 100644 --- a/subdomains/templatetags/subdomainurls.py +++ b/subdomains/templatetags/subdomainurls.py @@ -38,7 +38,7 @@ def url(context, view, subdomain=UNSET, *args, **kwargs): subdomain = getattr(request, 'subdomain', None) else: subdomain = None - elif subdomain is '': + elif not subdomain: subdomain = None return reverse(view, subdomain=subdomain, args=args, kwargs=kwargs) diff --git a/subdomains/tests/tests.py b/subdomains/tests/tests.py index 5c8c199..d73703f 100644 --- a/subdomains/tests/tests.py +++ b/subdomains/tests/tests.py @@ -232,6 +232,14 @@ def test_without_subdomain(self): rendered = template.render(context).strip() self.assertEqual(rendered, 'http://%s/' % self.DOMAIN) + def test_with_empty_subdomain(self): + defaults = {'view': 'home'} + template = self.make_template('{% url view subdomain="" %}') + + context = Context(defaults) + rendered = template.render(context).strip() + self.assertEqual(rendered, 'http://%s/' % self.DOMAIN) + def test_with_subdomain(self): defaults = {'view': 'home'} template = self.make_template('{% url view subdomain=subdomain %}')