Fixed #22362 -- Improved AuthenticationMiddleware assertion message.

Thanks Keryn Knight.
This commit is contained in:
Tim Graham 2014-03-31 08:10:59 -04:00
parent 981b864fbd
commit 246face209
1 changed files with 6 additions and 2 deletions

View File

@ -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))