我当前的django网站有问题。 当我使用http://localhost/homepage运行我的应用程序时,出现以下错误:
[Sun Oct 21 13:43:22.384951 2018] [ssl:warn] [pid 1744:tid 756] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 21 13:43:22.459176 2018] [ssl:warn] [pid 1744:tid 756] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 21 13:43:22.501166 2018] [mpm_winnt:notice] [pid 1744:tid 756] AH00455: Apache/2.4.33 (Win32) OpenSSL/1.1.0h mod_wsgi/4.6.4 Python/3.7 PHP/7.2.7 configured -- resuming normal operations
[Sun Oct 21 13:43:22.501658 2018] [mpm_winnt:notice] [pid 1744:tid 756] AH00456: Apache Lounge VC15 Server built: Mar 28 2018 12:12:41
[Sun Oct 21 13:43:22.501658 2018] [core:notice] [pid 1744:tid 756] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Oct 21 13:43:22.510936 2018] [mpm_winnt:notice] [pid 1744:tid 756] AH00418: Parent: Created child process 5932
[Sun Oct 21 13:43:23.325421 2018] [ssl:warn] [pid 5932:tid 788] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 21 13:43:23.394264 2018] [ssl:warn] [pid 5932:tid 788] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Oct 21 13:43:23.505603 2018] [mpm_winnt:notice] [pid 5932:tid 788] AH00354: Child: Starting 150 worker threads.
[Sun Oct 21 13:43:27.929295 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] mod_wsgi (pid=5932): Failed to exec Python script file 'C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py'.
[Sun Oct 21 13:43:27.929295 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] mod_wsgi (pid=5932): Exception occurred processing WSGI script 'C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py'.
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] Traceback (most recent call last):\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py", line 16, in <module>\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] application = get_wsgi_application()\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] django.setup(set_prefix=False)\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 56, in __getattr__\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] self._setup(name)\r
[Sun Oct 21 13:43:27.932041 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 43, in _setup\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] self._wrapped = Settings(settings_module)\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 106, in __init__\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "c:\\program files (x86)\\python37-32\\lib\\importlib\\__init__.py", line 127, in import_module\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] return _bootstrap._gcd_import(name[level:], package, level)\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked\r
[Sun Oct 21 13:43:27.932525 2018] [wsgi:error] [pid 5932:tid 2180] [client ::1:59814] ModuleNotFoundError: No module named 'Sportdata'\r
[Sun Oct 21 13:43:28.873965 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] mod_wsgi (pid=5932): Failed to exec Python script file 'C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py'., referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874454 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] mod_wsgi (pid=5932): Exception occurred processing WSGI script 'C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py'., referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] Traceback (most recent call last):\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py", line 16, in <module>\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] application = get_wsgi_application()\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] django.setup(set_prefix=False)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.874944 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\__init__.py", line 19, in setup\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 56, in __getattr__\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] self._setup(name)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 43, in _setup\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] self._wrapped = Settings(settings_module)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\site-packages\\django\\conf\\__init__.py", line 106, in __init__\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "c:\\program files (x86)\\python37-32\\lib\\importlib\\__init__.py", line 127, in import_module\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875433 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked\r, referer: http://localhost/homepage
[Sun Oct 21 13:43:28.875925 2018] [wsgi:error] [pid 5932:tid 2172] [client ::1:59815] ModuleNotFoundError: No module named 'Sportdata'\r, referer: http://localhost/homepage
我在xampp中的配置如下:
LoadFile "c:/program files (x86)/python37-32/python37.dll"
LoadModule wsgi_module "c:/program files (x86)/python37-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
WSGIPythonHome "c:/program files (x86)/python37-32"
Alias /static/ "C:/Users/michse/PycharmProjects/Django-Sites/Sportdata germany/static"
<Directory "C:/Users/michse/PycharmProjects/Django-Sites/Sportdata germany/static">
Require all granted
</Directory>
WSGIScriptAlias / "C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/wsgi.py"
WSGIPythonPath "C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata"
<Directory "C:/Users/michse/Desktop/HP Sportdata/Sportdata/Sportdata/">
<Files "wsgi.py">
Require all granted
</Files>
</Directory>
我在使用的项目目录中的结构是这样的:
Desktop -> HP Sportdata
- Sportdata
- homepage
- migrations
- templates
- several .html documents
- __init__.py
- admin.py
- apps.py
- contactform.py
- models.py
- tests.py
- urls.py
- views.py
- Sportdata
- __init__.py
- settings.py
- urls.py
- wsgi.py
- static
- admin
- css
- fonts
- img
- js
- homepage
- css
- base.css
- pictures
- manage.py
在我的设置文件中,完成了以下配置:
"""
Django settings for sdgermany project.
Generated by 'django-admin startproject' using Django 2.0.7.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '<hidden>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'homepage.apps.HomepageConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
]
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',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'Sportdata.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 = 'Sportdata.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'homepage',
'USER': 'python',
'PASSWORD': 'login',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
INTERNAL_IPS = { '127.0.0.1', }
我的网址看起来与django页面上的示例非常相似:
The root configuration:
"""sdgermany URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
import debug_toolbar
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls')),
path('homepage/', include('homepage.urls')),
path(r'^__debug__', include(debug_toolbar.urls))
]
and the homepage configuration:
from django.urls import path
from . import views
urlpatterns = [ path( '', views.index, name = 'index' ),
path( 'teampage', views.teampage, name='teampage' ),
path( 'services', views.services, name='services' ),
path( 'references', views.references, name='references' ),
path( 'contact', views.contact, name='contact' ),
]
也许我只是盲目地看不到错误,但是我尝试了几种选择,但没有使它运行。所以我需要你的帮助:)
让我知道何时需要更多信息
提前谢谢大家