I\'m running a virtualenv to try to learn Django, but for whatever reason after installing Django and when I try to access the default Django start page, I get the following
I have created a Django project with Django 1.7 and tried to run it with Django 1.6.8. And I got the same error. I have just removed
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
from
MIDDLEWARE_CLASSES =
in my project's settings.py. And it works.
I was getting the same error. But i had forgotten to get into my VirtualEnv BEFORE running my server.
So make sure that from terminal you first activate virtualenv: source env/bin/activate
Then run: python manage.py runserver
easy solution
just remove
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
from
MIDDLEWARE_CLASSES = (
...
...
)
in your project's settings.py
then, it should work!
Make sure that you are running $ source bin/activate from the root of your project. Otherwise just go ahead and wipe out your project and make a new one. And if you want to be a django dev get ready to make lots of virtualenv's.
When working on separate branches for example, it's sometimes easier to have two different virtualenv's, etc and when you move to the server you'll probably be running from a virtualenv as well. So it's a good idea to get good at making them and going through the steps.
It's easy to copy files between directories with the $ cp command.
run
python3 manage.py runserver
instead of
python manage.py runserver
or
./manage.py runserver
You can also edit the first line of manage.py replacing
\#!/usr/bin/env python
by
\#!/usr/bin/env python3
and then run ./manage.py runserver
(it seem to work, I don't know if it's authorized by django's project)
It looks like you are using a version of django prior to version 1.7 (1.6.4 to be specific), and SessionAuthenticationMiddleware was not introduced until django 1.7. Hence the error
Documentation can be found here https://docs.djangoproject.com/en/1.7/ref/middleware/#django.contrib.auth.middleware.SessionAuthenticationMiddleware
On the bottom right, you can choose the version of django. Select the appropriate version, and follow the tutorial specific to the version of django you are using.