diff --git a/django/contrib/auth/middleware.py b/django/contrib/auth/middleware.py index 3ee742446d..31d42e13cf 100644 --- a/django/contrib/auth/middleware.py +++ b/django/contrib/auth/middleware.py @@ -13,8 +13,12 @@ def get_user(request): class AuthenticationMiddleware(object): def process_request(self, request): - assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." - + assert hasattr(request, 'session'), ( + "The Django authentication middleware requires session middleware " + "to be installed. Edit your MIDDLEWARE_CLASSES setting to insert " + "'django.contrib.sessions.middleware.SessionMiddleware' before " + "'django.contrib.auth.middleware.AuthenticationMiddleware'." + ) request.user = SimpleLazyObject(lambda: get_user(request))