Skip to content

Commit

Permalink
Avoided a django-hosts deprecation warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
charettes committed Dec 20, 2015
1 parent 37d12f0 commit 16c8dd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tenancy/middleware.py
Expand Up @@ -20,11 +20,11 @@ def __init__(self):
)
path = "%s.%s" % (self.__module__, self.__class__.__name__)
for middleware in settings.MIDDLEWARE_CLASSES:
if middleware == 'django_hosts.middleware.HostsMiddleware':
if middleware == 'django_hosts.middleware.HostsRequestMiddleware':
break
elif middleware == path:
raise ImproperlyConfigured(
"Make sure that 'django_hosts.middleware.HostsMiddleware' "
"Make sure that 'django_hosts.middleware.HostsRequestMiddleware' "
"is placed before '%s' in your `MIDDLEWARE_CLASSES` "
"setting." % path
)
Expand Down
13 changes: 7 additions & 6 deletions tests/test_hosts.py
Expand Up @@ -21,10 +21,11 @@ def django_hosts_installed_setup(func):
func = override_settings(
DEFAULT_HOST='default',
ROOT_HOSTCONF='tests.hosts',
MIDDLEWARE_CLASSES=(
'django_hosts.middleware.HostsMiddleware',
'tenancy.middleware.TenantHostMiddleware'
)
MIDDLEWARE_CLASSES=[
'django_hosts.middleware.HostsRequestMiddleware',
'tenancy.middleware.TenantHostMiddleware',
'django_hosts.middleware.HostsResponseMiddleware',
],
)(func)
return skipUnless(
django_hosts,
Expand Down Expand Up @@ -52,13 +53,13 @@ def test_not_installed(self):
@override_settings(
MIDDLEWARE_CLASSES=(
'tenancy.middleware.TenantHostMiddleware',
'django_hosts.middleware.HostsMiddleware'
'django_hosts.middleware.HostsRequestMiddleware',
)
)
def test_wrong_order(self):
self.assertRaisesMessage(
ImproperlyConfigured,
"Make sure that 'django_hosts.middleware.HostsMiddleware' is "
"Make sure that 'django_hosts.middleware.HostsRequestMiddleware' is "
"placed before 'tenancy.middleware.TenantHostMiddleware' in your "
"`MIDDLEWARE_CLASSES` setting.",
TenantHostMiddleware
Expand Down

0 comments on commit 16c8dd8

Please sign in to comment.