'CsrfViewMiddleware' object is not iterable
<p>I am new to Django, and I just took over from another developer on this project. All I have done so far is clone the code from git and install the dependencies.</p>

<p>Immediately after setting up the project, and running <code>python manager.py runserver</code> and going to <code>localhost:8000/admin</code> I get an error stating the <code>TypeError at /admin/login/</code>, <code>'CsrfViewMiddleware' object is not iterable</code>:</p>

<blockquote>
  <p>Traceback:</p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/exception.py"
  in inner
    39.             <code>response = get_response(request)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
  in _legacy_get_response
    249.             <code>response = self._get_response(request)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
  in _get_response
    217.                 <code>response = self.process_exception_by_middleware(e, request)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
  in _get_response
    215.                 <code>response = response.render()</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/response.py"
  in render
    109.             <code>self.content = self.rendered_content</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/response.py"
  in rendered_content
    86.         <code>content = template.render(context, self._request)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/backends/django.py"
  in render
    66.             <code>return self.template.render(context)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/base.py"
  in render
    206.                 <code>with context.bind_template(self):</code></p>
  
  <p>File "/usr/lib/python3.5/contextlib.py" in <code>__enter__</code>
    59.             <code>return next(self.gen)</code></p>
  
  <p>File
  "/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/context.py"
  in bind_template
    236.             <code>updates.update(processor(self.request))</code></p>
  
  <p>Exception Type: TypeError at /admin/login/</p>
  
  <p>Exception Value: 'CsrfViewMiddleware' object is not iterable</p>
</blockquote>

<p><a href="http://i.stack.imgur.com/nypI7.png" rel="nofollow"><img src="http://i.stack.imgur.com/nypI7.png" alt="enter image description here"></a></p>

<p>I would post code from the source code but I can't figure where in the source the cause of this might possibly be.</p>

<p>My settings.py:</p>

<pre><code>import os
from datetime import datetime
from django.conf.global_settings import EMAIL_USE_SSL
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'ourapp',
    'social.apps.django_app.default',
    'sendgrid',
    'corsheaders',
)

MIDDLEWARE_CLASSES = (
    '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',
    'ourapp.middleWare.authenticationMiddleware.AuthenticationMiddleware'
)

ROOT_URLCONF = ''

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
        'django.middleware.csrf.CsrfViewMiddleware',
        'corsheaders.middleware.CorsMiddleware',
                'social.apps.django_app.context_processors.backends',
                'social.apps.django_app.context_processors.login_redirect',
            ],
        },
    },
]
</code></pre>

<p>(Sorry about the lack of indentation.)
Any ideas on how to proceed from here would be greatly appreciated!</p>

<p>Try removing <code>'django.middleware.csrf.CsrfViewMiddleware',</code> from <code>TEMPLATES</code>. Probably <code>'corsheaders.middleware.CorsMiddleware',</code> too</p>

python django django-templates django-views django-csrf