I started my virtualenv. Then started my server via python manage.py runserver. I ended up visiting my django site and getting the following error.

(venv)N$ python manage.py runserver
Validating models...

0 errors found
June 11, 2015 - 19:27:19
Django version 1.6.5, using settings 'nirsite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
    return self.application(environ, start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
    self.load_middleware()
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
    mw_class = import_by_path(middleware_path)
  File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 31, in import_by_path
    error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class

I have already checked out this Stackoverflow, and I couldn't resolve the problem with any of these answers. Seeing as the venv is set up properly and I don't think getting rid of any of the Middlewares makes sense.

I can provide more information upon request.

Update:

Okay this looks like a problem with my virtualenv. After I started this virtualenv, I did pip install django within it, but now if I type that that within it again, I get the following:

Requirement already satisfied (use --upgrade to upgrade): django in /Library/Python/2.7/site-packages

This isn't pointing to my virtualenv I think, so I am guessing this is a problem. Why didn't the venv I was in install django? How can I fix this? And not run into the problem next time around?

2

There are 2 answers

0
Aarif On

for Django 2.0 and above

SessionAuthenticationMiddleware was removed in Django 2.0 (see Django 2.0 release notes here)

just remove it from MIDDLEWARE_CLASSES

posting it here because I faced the same problem when upgrading to Django 2

0
Vadim Shatalov On

You wrote : Django 1.8

But look at log : Django version 1.6.5

There is the problem - check django version in virtualenv or may be you just forgot activate virtualenv