我在这里是因为我有一个问题,我在过去2天中确实尝试自己解决,但没有任何结果。 我是django的新手,还是stackOverflow的新手,所以很抱歉,如果我犯了愚蠢的错误。 我目前在django网站上工作,事情不多,但是在页面加载时出现了一些问题(错误并非每次都发生)。 当我加载页面时,我经常会有一个我不明白的错误记录。 访问某些文件似乎是一个问题,但是我不确定。
我尝试了很多事情,我重新安装了其他版本的python,尝试了其他版本的django,并尝试更改设置。但是没有任何作用
我当前正在使用python 3.6和:
错误日志
Traceback (most recent call last):
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
[28/Mar/2019 16:01:46] "GET /static/favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 57684)
Traceback (most recent call last):
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\ex.antonin.alliance\Documents\env_portail\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\ex.antonin.alliance\Documents\env_portail\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\ex.antonin.alliance\Documents\env_portail\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\ex.antonin.alliance\Documents\env_portail\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\ex.antonin.alliance\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
设置
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'b$s$%qh3)5xuri^#30b7fj#kvmh#j30zl382*3(%969jxp6)o1'
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'EfficientIP',
]
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 = 'portail.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
os.path.join(BASE_DIR, 'connection/templates'),
],
'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 = 'portail.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
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',
},
]
LANGUAGE_CODE = 'fr-FR'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
# CELERY STUFF
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Europe/Paris'
我的html文件的标题
{% load static %}
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="{% static 'bootstrap.min.css' %}" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="{% static 'bootstrap.min.js' %}"></script>
<title>Portail</title>
</head>