Browse files

[1.7.x] Fixed #22362 -- Improved AuthenticationMiddleware assertion m…

…essage.

Thanks Keryn Knight.

Backport of 246face from master
  • Loading branch information...
1 parent 07c42ce commit ef3734693277242e98996f591d9acf39e8819441 @timgraham timgraham committed Mar 31, 2014
Showing with 6 additions and 2 deletions.
  1. +6 −2 django/contrib/auth/middleware.py
View
8 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))

0 comments on commit ef37346

Please sign in to comment.