[英]Django Hello World web app on a Windows Server VM
晚上好,我正在尝试在Azure云上设置hello world应用程序。 我正在Windows Server vm上关注Django Hello World Web应用程序教程
完成所有设置后,当我导航到http:// localhost /时
我收到以下错误
ils \\ module_loading.py”,第20行,在import_string模块= import_module(module_path)文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ importlib__init __。py”,第126行,在import_module返回中_bootstrap._gcd_import(name [level:],程序包,级别)文件“”,第994行,在_gcd_import文件“”,第971行,在_find_and_load文件“”,第955行,在_find_and_load_unlocked文件“”,在_load_unlocked,行665 exec_module中的文件“”,第678行,_call_with_frames_removed文件中的文件“,”,第219行c_ \\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ contrib \\ auth \\ middleware .py“,第4行,从django.contrib.auth.backends中导入RemoteUserBackend文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ contrib \\ auth \\ backends .py“,第4行,来自django.contrib.auth.models导入权限文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ contrib \\ auth \\ models .py“,第4行,来自django.co ntrib.auth.base_user导入AbstractBaseUser,BaseUserManager文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ contrib \\ auth \\ base_user.py”,类52 AbstractBaseUser(models.Model):文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ db \\ models \\ base.py”,第110行,在新的 app_config = apps.get_tained_app_config(模块)文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ apps \\ registry.py”,第247行,位于get_ contains_app_config self.check_apps_ready()中文件“ c:\\ users \\ compUser \\ appdata \\ local \\ programs \\ python \\ python36 \\ lib \\ site-packages \\ django \\ apps \\ registry.py”第125行,位于check_apps_ready中,引发AppRegistryNotReady(“尚未加载应用程序。 ”)django.core.exceptions.AppRegistryNotReady:应用尚未加载。 StdOut:StdErr:
我在一些帖子中看到,人们建议像为独立应用程序那样添加django.setup(),该命令无法正常工作,或者我将其放在错误的位置。 我试图运行python manage.py runserver,它运行无误。
以下是我的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()" />
参考django源代码 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.