I have an almost fresh install of django and when I try to python manage.py runserver.It is is giving me this error:
ImproperlyConfigured: WSGI application 'myproject.wsgi.application' could not be loaded; Error importing module.
settings.py
WSGI_APPLICATION = 'myproject.wsgi.application'
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
application = get_wsgi_application()
Comment out the
#'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
in your settings.py file in Middleware
I encountered the same problem because I added the debug_toolbar Middleware to my settings.py
'debug_toolbar.middleware.DebugToolbarMiddleware',
I solved the problem by removing the debug_toolbar Middleware. I also had to remove debug_toolbar from my INSTALLED APPS.
From my experience this happens when I try to execute runserver but the I haven't installed all custom MIDDLEWARE in setting.py. After identifying and installing the middlewares the error is resolved.
Check for the stack trace - you might find answer few lines above the line "The above exception was the direct cause of the following exception:"
It may caused for example by using of middleware from some uninstalled third party app etc.
Check the settings.py,
MIDDLEWARE=[
'whitenoise.middleware.WhiteNoiseMiddleware',
]
remove 'whitenoise.middleware.WhiteNoiseMiddleware',
or install Whitenoise (pip install whitenoise)