Django ImproperlyConfigured: WSGI application '

2019-03-28 06:42发布

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()

5条回答
Ridiculous、
2楼-- · 2019-03-28 06:54

Comment out the

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

in your settings.py file in Middleware

查看更多
老娘就宠你
3楼-- · 2019-03-28 06:59

Check the settings.py,

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

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

查看更多
走好不送
4楼-- · 2019-03-28 07:07

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.

查看更多
放我归山
5楼-- · 2019-03-28 07:08

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.

查看更多
Deceive 欺骗
6楼-- · 2019-03-28 07:19

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.

查看更多
登录 后发表回答