gpt4 book ai didi

django - 测试 Django View 导致 "AttributeError: ' NoneType' 对象没有属性 'handler500'“错误

转载 作者:行者123 更新时间:2023-11-28 20:34:17 24 4
gpt4 key购买 nike

我只想使用下面的代码开始测试 Django View :

from django.test.client import Client
c = Client()
response = c.get('/search/keyword')
print response.content

它只是抛出以下错误信息:

 "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 286, in get
response = self.request(**r)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 230, in request
response = self.handler(environ)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 74, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 143, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 178, in handle_uncaught_exception
callback, param_dict = resolver.resolve500()
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 268, in resolve500
return self._resolve_special('500')
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 258, in _resolve_special
callback = getattr(self.urlconf_module, 'handler%s' % view_type)
AttributeError: 'NoneType' object has no attribute 'handler500'

该 View 在浏览器中工作。上面的代码有什么问题?

最佳答案

关于django - 测试 Django View 导致 "AttributeError: ' NoneType' 对象没有属性 'handler500'“错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2436598/

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