'WSGIRequest' object has no attribute 'session' while upgrading from django 1.3 to 1.9
<p>Similar to this question <a href="http://stackoverflow.com/questions/11783404/wsgirequest-object-has-no-attribute-session">&#39;WSGIRequest&#39; object has no attribute &#39;session&#39;</a></p>

<p>But my MIDDLEWARE classes are in the correct order.</p>

<pre class="lang-py prettyprint-override"><code>INSTALLED_APPS = [
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'membership',
    'treebeard',
    'haystack',
    'reversion',
]

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

<p>I am redirecting to login</p>

<pre class="lang-py prettyprint-override"><code>url(r'^$',  RedirectView.as_view(url='login/')),
url(r'^login/$', 'membership.views.loginView', name='login'),
</code></pre>

<p>and then</p>

<pre class="lang-py prettyprint-override"><code>def loginView(request):
    a = request.session
</code></pre>

<p>Throws the error</p>

<p><code>MIDDLEWARE</code> is a new setting in 1.10 that will replace the old <code>MIDDLEWARE_CLASSES</code>.</p>

<p>Since you're currently on 1.9, Django doesn't recognize the <code>MIDDLEWARE</code> setting. You should use the <code>MIDDLEWARE_CLASSES</code> setting instead:</p>

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

python django django-middleware