Django : 'WSGIRequest' object has no attribute 'user'? - AuthenticationMiddleware & SessionAuthenticationMiddleware are in sequence
<p>Getting the following error while try to access the django admin panel.</p>

<pre><code>Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/

Django Version: 1.9.8
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'bookapp']
Installed Middleware:
['django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware']

Traceback:

File "/Library/Python/2.7/site-packages/django/core/handlers/base.py"     in get_response
  149.                     response =         self.process_exception_by_middleware(e, request)

File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in wrapper
  265.                 return self.admin_view(view, cacheable)(*args, **kwargs)

File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in inner
  233.             if not self.has_permission(request):

File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" in has_permission
  173.         return request.user.is_active and request.user.is_staff

Exception Type: AttributeError at /admin/
Exception Value: 'WSGIRequest' object has no attribute 'user'
</code></pre>

<p>Here is my middleware settings in settings.py</p>

<pre><code>MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
</code></pre>

<p>I have also tried with clearing cache like cleared migrations and     deleted database. But it won't work for me.</p>

<p>Can anybody knows what's the issue here?</p>