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
Just run it in Python 3 instead:
python3 manage.py runserver
If that would work, consider also applying some app migrations via: python3 manage.py migrate
.
I have the same error:
File "C:\Users\DANI3\Envs\recetario\lib\site-packages\django\utils\module_loading.py", line 23, in import_string
return getattr(module, class_name)
django.core.exceptions.ImproperlyConfigured: WSGI application 'recetario.wsgi.application' could not be loaded; Error importing module: 'Module "social_django.middleware" does not define a "SocialAythExceptionMiddleware" attribute/class'
I corrected the error make this change:
'social_django.middleware.SocialAuthExceptionMiddleware',
So, I just ran a fresh install of my virtualenv and started the server, and now it's working as expected. Problem solved.
As we can see in Django 1.8 release notes
django.contrib.auth.middleware.SessionAuthenticationMiddleware was added in Django 1.7.
And you are using Django-1.6.5
in your virtual environment, hence the does not define
error.
Probably you have a newer version of Django installed in your "normal" environment and the server runs correctly. To fix this upgrade Django version inside your virtual environment (prior to updating Django be sure to activate your virtual environment!)
Now to add my two cents to the answers, because everything until now was repetition from ZZY and user1776955
If you run pip install -U Django
you will probably bump your version to something higher than 1.10 and then the following will apply:
In Django 1.10, session verification will be enabled regardless of whether or not SessionAuthenticationMiddleware is enabled (at which point SessionAuthenticationMiddleware will have no significance)
Hence it will be safe to delete it and if you update past 2.0 you will HAVE to delete it because Django 2.0 release notes state that:
The SessionAuthenticationMiddleware class is removed. It provided no functionality since session authentication is unconditionally enabled in Django 1.10.
Also a bit unrelated but relevant when updating to this version is that
Support for old-style middleware using settings.MIDDLEWARE_CLASSES is removed
As far as my experience goes it is enough to change MIDDLEWARE_CLASSES
to just MIDDLEWARE
and delete 'django.contrib.auth.middleware.SessionAuthenticationMiddleware'
from the list.
I am running Windows7/64 version, had the same error. Agreed with user1776955, who pointed out the version problem of Django. so the easiest way to do is pointing to the Django-admin.py in shell. In my case, it is: python env\scripts\django-admin.py startproject my_django15_project
Refer to the doc, the Django in your active virtualenv must be Django 1.7. And:
This middleware must appear after django.contrib.auth.middleware.AuthenticationMiddleware in MIDDLEWARE_CLASSES
Does it solve your issue?