Django配置不正确:无法加载WSGI应用程序“ myproject.wsgi.application”;错误导入模块 [英] Django ImproperlyConfigured: WSGI application 'myproject.wsgi.application' could not be loaded; Error importing module
问题描述
我安装了几乎全新的django,并且当我尝试使用python manage.py runserver时,它给了我这个错误:
I have an almost fresh install of django and when I try to python manage.py runserver.It is is giving me this error:
配置不正确:WSGI应用程序'myproject.wsgi.application'无法加载;导入模块时出错。
ImproperlyConfigured: WSGI application 'myproject.wsgi.application' could not be loaded; Error importing module.
settings.py
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()
推荐答案
根据我的经验,当我尝试执行 runserver 但未在setting.py中安装所有自定义的 MIDDLEWARE 时,会发生这种情况。确定并安装中间件后,错误得以解决。
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.
这篇关于Django配置不正确:无法加载WSGI应用程序“ myproject.wsgi.application”;错误导入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!