2 回答
TA贡献1793条经验 获得超6个赞
某些中间件已过时或已移动/重命名。尝试使用 django 3 中的默认中间件列表:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
TA贡献1818条经验 获得超3个赞
我得到了同样的错误:
django.core.exceptions.ImproperlyConfigured:无法加载 WSGI 应用程序“core.wsgi.application”;导入模块时出错。
当我将项目中未安装的包“hello”MIDDLEWARE添加到中时settings.py:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'hello', # 'hello' package doesn't exist
]
MIDDLEWARE因此,在将它们添加到以下位置之前,不要忘记安装所需的软件包settings.py:
pip install <package>
添加回答
举报