Django Hello World虚拟机上的Hello World Web应用程序

晚上好,我正试着在天蓝色的云上设置你好世界的应用程序。 我正在关注windows server vm上的教程Django hello world web应用程序

在我导航到http:// localhost /

我得到以下错误

读取WSGI处理程序时发生错误:Traceback(最近一次调用最后一次):文件“c: users compUser appdata local programs python python36 lib site-packages wfastcgi.py”,行791 env,handler = read_wsgi_handler(response.physical_path)在read_wsgi_handler handler = get_wsgi_handler(os)中,第633行的文件“c: users compUser appdata local programs python python36 lib site-packages wfastcgi.py” .getenv(“WSGI_HANDLER”))文件“c: users compUser appdata local programs python python36 lib site-packages wfastcgi.py”,第605行,在get_wsgi_handler handler = handler() c: users compUser appdata local programs python python36 lib site-packages django core handlers wsgi.py“,第151行,在init self.load_middleware() compUser appdata local programs python python36 lib site-packages django core handlers base.py“,第81行,在load_middleware中间件= import_string(middleware_path)文件”c: users compUser 应用程序数据本地程序 python的 python36 LIB 站点包 Django的 UT 在import_module返回的第126行中,在import_string module = import_module(module_path)文件“c: users compUser appdata local programs python python36 lib importlib__init __。py”中找到“ils module_loading.py” _bootstrap._gcd_import(name [level:],package,level)_find_and_load_unlocked File“”,第665行,_load_unlocked中的_gcd_import File“”,第971行,文件“”,第678行,在exec_module文件“”,第219行,在_call_with_frames_removed文件“c: users compUser appdata local programs python python36 lib site-packages django contrib auth middleware .py“,第4行,来自django.contrib.auth.backends import 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 import class AbstractBaseUser,BaseUserManager在第52行的文件“c: users compUser appdata local programs python python36 lib site-packages django contrib auth base_user.py” AbstractBaseUser(models.Model):在新的 app_config中,第110行的文件“c: users compUser appdata local programs python python36 lib site-packages django db models base.py” apps.get_containing_app_config(module)get_containing_app_config self.check_apps_ready()中的第247行文件“c: users compUser appdata local programs python python36 lib site-packages django apps registry.py”文件“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: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>

这是我的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源代码。

链接地址: http://www.djcxy.com/p/40575.html

上一篇: Django Hello World web app on a Windows Server VM

下一篇: django guardian importerror but other examples work