Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[1.7.x] Fixed #22362 -- Improved AuthenticationMiddleware assertion m…
…essage.

Thanks Keryn Knight.

Backport of 246face from master
  • Loading branch information
timgraham committed Mar 31, 2014
1 parent 07c42ce commit ef37346
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions django/contrib/auth/middleware.py
Expand Up @@ -13,8 +13,12 @@ def get_user(request):


class AuthenticationMiddleware(object): class AuthenticationMiddleware(object):
def process_request(self, request): 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)) request.user = SimpleLazyObject(lambda: get_user(request))




Expand Down

0 comments on commit ef37346

Please sign in to comment.