Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django ImproperlyConfigured: WSGI application 'myproject.wsgi.application' could not be loaded; Error importing module

I have an almost fresh install of django and when I run python manage.py runserver. It 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()
like image 840
tommyp Avatar asked Dec 13 '17 19:12

tommyp


3 Answers

Check the settings.py,

MIDDLEWARE=[
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

remove 'whitenoise.middleware.WhiteNoiseMiddleware', or install Whitenoise (pip install whitenoise)

like image 103
tnductam Avatar answered Sep 19 '22 22:09

tnductam


Comment out the

#'django.contrib.auth.middleware.SessionAuthenticationMiddleware',

in your settings.py file in Middleware

like image 18
skuli434 Avatar answered Nov 11 '22 18:11

skuli434


From my experience this happens when I try to execute runserver but I haven't installed all custom MIDDLEWARE in setting.py. After identifying and installing the middlewares the error is resolved.

like image 10
nixenerlan Avatar answered Nov 11 '22 18:11

nixenerlan