Django Hello World web app on a Windows Server VM
Good Evening, I am trying to setup hello world app on azure cloud. I am following the tutorial Django hello world web app on windows server vm
After doing all the set up when I navigate to the http://localhost/
I get following error
Error occurred while reading WSGI handler: Traceback (most recent call last): File "c:userscompUserappdatalocalprogramspythonpython36libsite-packageswfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response.physical_path) File "c:userscompUserappdatalocalprogramspythonpython36libsite-packageswfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) File "c:userscompUserappdatalocalprogramspythonpython36libsite-packageswfastcgi.py", line 605, in get_wsgi_handler handler = handler() File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocorehandlerswsgi.py", line 151, in init self.load_middleware() File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocorehandlersbase.py", line 81, in load_middleware middleware = import_string(middleware_path) File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangout ilsmodule_loading.py", line 20, in import_string module = import_module(module_path) File "c:userscompUserappdatalocalprogramspythonpython36libimportlib__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:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocontribauthmiddleware.py", line 4, in from django.contrib.auth.backends import RemoteUserBackend File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocontribauthbackends.py", line 4, in from django.contrib.auth.models import Permission File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocontribauthmodels.py", line 4, in from django.co ntrib.auth.base_user import AbstractBaseUser, BaseUserManager File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangocontribauthbase_user.py", line 52, in class AbstractBaseUser(models.Model): File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangodbmodelsbase.py", line 110, in new app_config = apps.get_containing_app_config(module) File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangoappsregistry.py", line 247, in get_containing_app_config self.check_apps_ready() File "c:userscompUserappdatalocalprogramspythonpython36libsite-packagesdjangoappsregistry.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:
I saw in some post, people suggested to add django.setup() like for standalone apps, that did not work or I put that in wrong spot. I tried to run python manage.py runserver and it ran without error.
Following is my web.config file
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
<add key="PYTHONPATH" value="C:inetpubwwwrootresumeApp" />
<add key="DJANGO_SETTINGS_MODULE" value="resumeApp.settings" />
<!-- optional settings -->
<add key="WSGI_LOG" value="C:inetpubwwwrootresumeAppLogsresumeApp.log" />
</appSettings>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:userscompUserappdatalocalprogramspythonpython36python.exe|c:userscompUserappdatalocalprogramspythonpython36libsite-packageswfastcgi.py"
resourceType="Unspecified" />
</handlers>
</system.webServer>
This is my 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/'
In web.config
, replace:
<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
with:
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
refer to django source code.
链接地址: http://www.djcxy.com/p/40576.html上一篇: 如何设置mousemove更新速度?