diff --git a/tos/middleware.py b/tos/middleware.py index d740db5..2233fbe 100644 --- a/tos/middleware.py +++ b/tos/middleware.py @@ -25,7 +25,7 @@ class UserAgreementMiddleware(MiddlewareMixin): return None # Ignore ajax requests - if request.is_ajax(): + if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest': return None # Don't redirect users when they're trying to get to the confirm page diff --git a/tos/tests/test_middleware.py b/tos/tests/test_middleware.py index 5dffd06..bb64376 100644 --- a/tos/tests/test_middleware.py +++ b/tos/tests/test_middleware.py @@ -111,9 +111,6 @@ class TestMiddleware(TestCase): @modify_settings( - MIDDLEWARE_CLASSES={ - 'append': 'tos.middleware.UserAgreementMiddleware', - }, MIDDLEWARE={ 'append': 'tos.middleware.UserAgreementMiddleware', }, @@ -142,6 +139,9 @@ class BumpCoverage(TestCase): def test_ajax_request(self): class Request(object): method = 'GET' + META = { + 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest' + } def is_ajax(self): return True