亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法加載 WSGI 應用程序“mysite.wsgi.application”;導入模塊時出錯

無法加載 WSGI 應用程序“mysite.wsgi.application”;導入模塊時出錯

繁星coding 2023-09-26 15:10:47
我使用 django 3.1.1 和 Python 3.8.5。我想創建簡單的博客。我使用一些舊代碼,其中程序員可能使用 django 1.11,所以我改變了很多東西,但現在我陷入困境我收到錯誤    raise ImproperlyConfigured(django.core.exceptions.ImproperlyConfigured: WSGI application 'mysite.wsgi.application' could not be loaded; Error importing module.當我嘗試刪除時WSGI_APPLICATION = 'mysite.wsgi.application'我收到一個錯誤ImportError: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class這是我的整個設置.py"""Django settings for mysite project.Generated by 'django-admin startproject' using Django 1.8.6.For more information on this file, seehttps://docs.djangoproject.com/en/1.8/topics/settings/For the full list of settings and their values, seehttps://docs.djangoproject.com/en/1.8/ref/settings/"""# Build paths inside the project like this: os.path.join(BASE_DIR, ...)import osBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = '*s@w*wx_w23k5vp%c%*aatqr42dsu3m$^(et@a(yrx$(4j-u*o'# SECURITY WARNING: don't run with debug turned on in production!DEBUG = TrueALLOWED_HOSTS = []SITE_ID = 1# Application definitionINSTALLED_APPS = (    'django.contrib.admin',    'django.contrib.auth',    'django.contrib.contenttypes',    'django.contrib.sessions',    'django.contrib.messages',    'django.contrib.staticfiles',    'django.contrib.sites',    'django.contrib.sitemaps',    'blog',    'taggit',    'haystack',)
查看完整描述

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',

]


查看完整回答
反對 回復 2023-09-26
?
泛舟湖上清波郎朗

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>


查看完整回答
反對 回復 2023-09-26
  • 2 回答
  • 0 關注
  • 233 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號