Windows 服务器虚拟机上的 Django Hello World Web 应用程序
Django Hello World web app on a Windows Server VM
晚上好,
我正在尝试在 azure cloud 上设置 hello world 应用程序。我正在学习教程 Django hello world web app on windows server vm
完成所有设置后,我导航到 http://localhost/
我收到以下错误
Error occurred while reading WSGI handler: Traceback (most recent call last):
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 605, in get_wsgi_handler handler = handler()
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\core\handlers\wsgi.py", line 151, in init self.load_middleware()
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\core\handlers\base.py", line 81, in load_middleware middleware = import_string(middleware_path)
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\utils\module_loading.py", line 20, in import_string module = import_module(module_path)
File "c:\users\compUser\appdata\local\programs\python\python36\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\middleware.py", line 4, in from django.contrib.auth.backends import RemoteUserBackend
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\backends.py", line 4, in from django.contrib.auth.models import Permission
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\models.py", line 4, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\base_user.py", line 52, in class AbstractBaseUser(models.Model):
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\db\models\base.py", line 110, in new app_config = apps.get_containing_app_config(module)
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config self.check_apps_ready()
File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. StdOut: StdErr:
我在一些 post 中看到,人们建议添加 django.setup() 之类的独立应用程序,但这没有用,或者我把它放在了错误的位置。我尝试 运行 python manage.py 运行 服务器并且它 运行 没有错误。
以下是我的web.config文件
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\resumeApp" />
<add key="DJANGO_SETTINGS_MODULE" value="resumeApp.settings" />
<!-- optional settings -->
<add key="WSGI_LOG" value="C:\inetpub\wwwroot\resumeApp\Logs\resumeApp.log" />
</appSettings>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\users\compUser\appdata\local\programs\python\python36\python.exe|c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py"
resourceType="Unspecified" />
</handlers>
</system.webServer>
这是我的settings.py
"""enter code hereDjango settings for resumeApp project.
Generated by 'django-admin startproject' using Django 1.11.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_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.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<removed>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
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',
]
ROOT_URLCONF = 'resumeApp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'resumeApp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
在web.config
中替换:
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
与:
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
晚上好, 我正在尝试在 azure cloud 上设置 hello world 应用程序。我正在学习教程 Django hello world web app on windows server vm
完成所有设置后,我导航到 http://localhost/
我收到以下错误
Error occurred while reading WSGI handler: Traceback (most recent call last): File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response.physical_path) File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py", line 605, in get_wsgi_handler handler = handler() File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\core\handlers\wsgi.py", line 151, in init self.load_middleware() File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\core\handlers\base.py", line 81, in load_middleware middleware = import_string(middleware_path) File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\utils\module_loading.py", line 20, in import_string module = import_module(module_path) File "c:\users\compUser\appdata\local\programs\python\python36\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\middleware.py", line 4, in from django.contrib.auth.backends import RemoteUserBackend File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\backends.py", line 4, in from django.contrib.auth.models import Permission File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\models.py", line 4, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\contrib\auth\base_user.py", line 52, in class AbstractBaseUser(models.Model): File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\db\models\base.py", line 110, in new app_config = apps.get_containing_app_config(module) File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config self.check_apps_ready() File "c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. StdOut: StdErr:
我在一些 post 中看到,人们建议添加 django.setup() 之类的独立应用程序,但这没有用,或者我把它放在了错误的位置。我尝试 运行 python manage.py 运行 服务器并且它 运行 没有错误。
以下是我的web.config文件
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\resumeApp" />
<add key="DJANGO_SETTINGS_MODULE" value="resumeApp.settings" />
<!-- optional settings -->
<add key="WSGI_LOG" value="C:\inetpub\wwwroot\resumeApp\Logs\resumeApp.log" />
</appSettings>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\users\compUser\appdata\local\programs\python\python36\python.exe|c:\users\compUser\appdata\local\programs\python\python36\lib\site-packages\wfastcgi.py"
resourceType="Unspecified" />
</handlers>
</system.webServer>
这是我的settings.py
"""enter code hereDjango settings for resumeApp project.
Generated by 'django-admin startproject' using Django 1.11.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_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.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<removed>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
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',
]
ROOT_URLCONF = 'resumeApp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'resumeApp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
在web.config
中替换:
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
与:
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />