Django Error : 'WSGIRequest' object has no attribute 'user'
<p><br>
I'm practicing django.<br>
Before I met this error message that is</p>

<blockquote>
  <p>'WSGIRequest' object has no attribute 'user'</p>
</blockquote>

<p>, I restart project and it was disappeared.<br>
Today, I met this error message again. I want to fix.<br>
It's OK when I open </p>

<blockquote>
  <p>localhost:8000</p>
</blockquote>

<p>but when i try to open </p>

<blockquote>
  <p>local host:8000/admin/</p>
</blockquote>

<p>error is occured.</p>

<p>I searched this error message at google and stackoverflow.<br>
I reordered my MIDDLEWARE in settings.py. It doesn't work.<br>
Please help me.<br></p>

<p>error message</p>

<pre><code>AttributeError at /admin/
'WSGIRequest' object has no attribute 'user'
Request Method: GET
Request URL:    http://localhost:8000/admin/
Django Version: 1.9.8
Exception Type: AttributeError
Exception Value:    
'WSGIRequest' object has no attribute 'user'
Exception Location: c:\todocal\myvenv\lib\site-packages\django\contrib\admin\sites.py in has_permission, line 173
Python Executable:  c:\todocal\myvenv\Scripts\python.exe
Python Version: 3.4.3
Python Path:    
['c:\\todocal',
 'C:\\Python34\\Lib',
 'C:\\WINDOWS\\SYSTEM32\\python34.zip',
 'C:\\Python34\\DLLs',
 'C:\\Python34',
 'c:\\todocal\\myvenv',
 'c:\\todocal\\myvenv\\lib\\site-packages']
Server time:    Sat, 13 Aug 2016 15:31:02 +0900
</code></pre>

<p>It's trace back</p>

<pre><code> Environment:


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

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



Traceback:

    File "c:\todocal\myvenv\lib\site-packages\django\core\handlers\base.py" in get_response
      149.                     response = self.process_exception_by_middleware(e, request)

    File "c:\todocal\myvenv\lib\site-packages\django\core\handlers\base.py" in get_response
      147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

    File "c:\todocal\myvenv\lib\site-packages\django\contrib\admin\sites.py" in wrapper
      265.                 return self.admin_view(view, cacheable)(*args, **kwargs)

    File "c:\todocal\myvenv\lib\site-packages\django\utils\decorators.py" in _wrapped_view
      149.                     response = view_func(request, *args, **kwargs)

    File "c:\todocal\myvenv\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
      57.         response = view_func(request, *args, **kwargs)

    File "c:\todocal\myvenv\lib\site-packages\django\contrib\admin\sites.py" in inner
      233.             if not self.has_permission(request):

    File "c:\todocal\myvenv\lib\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>It's settings.py</p>

<pre><code>

    """
    Django settings for todocal project.

    Generated by 'django-admin startproject' using Django 1.10.

    For more information on this file, see
    https://docs.djangoproject.com/en/1.10/topics/settings/

    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.10/ref/settings/
    """

    import os

    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = 'uij5f=ewy^jv$-=lzt!p%+lq2qv179$a6_lr=$774)@+$=a5(y'

    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True

    ALLOWED_HOSTS = []


    # Application definition

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'todocal_web',
    ]

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]

    ROOT_URLCONF = 'todocal.urls'

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ]

    WSGI_APPLICATION = 'todocal.wsgi.application'


    # Database
    # https://docs.djangoproject.com/en/1.10/ref/settings/#databases

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }


    # Password validation
    # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]


    # Internationalization
    # https://docs.djangoproject.com/en/1.10/topics/i18n/

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'Asia/Seoul'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True


    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.10/howto/static-files/

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')

</code></pre>