gpt4 book ai didi

python - Django wsgiref/handlers.py 像往常一样抛出异常

转载 作者:行者123 更新时间:2023-11-29 13:35:32 28 4
gpt4 key购买 nike

我正在按照这篇文章做一些 django TDD 示例 http://www.tdd-django-tutorial.com/tutorial/1/ .

但是当我尝试运行我的测试时,我总是遇到这个问题,

Creating test database for alias 'default'...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in get_response
return super(StaticFilesHandler, self).get_response(request)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 153, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/views/defaults.py", line 32, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
template, origin = find_template(template_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html

我试过 Postgres 和 Sqlite3,同样的输出让我很受折磨。

有谁知道我为什么会这样?提前谢谢你。

最佳答案

异常消息指出出了什么问题。

TemplateDoesNotExist: 500.html

看来您在 django 寻找您的模板的任何地方都缺少 500.html 文件。确保此文件存在。

我假设您的应用程序存在内部错误,并且 Django 正在尝试呈现它的 500 Internal Server Error 页面,但无法找到该页面。在此事件发生之前,Django 可能捕获了一个较早的异常。

关于python - Django wsgiref/handlers.py 像往常一样抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13357110/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com