Testing a Django view cause "AttributeError: 'NoneType' object has no attribute 'handler500'" error

Posted by jack on Stack Overflow See other posts from Stack Overflow or by jack
Published on 2010-03-12T23:47:51Z Indexed on 2010/03/13 6:25 UTC
Read the original article Hit count: 330

Filed under:
|
|
|

I just wanted to start testing a Django view using the code below:

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

It just throws out following error message:

 "/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'

The view works in browser. What's wrong with above code?

© Stack Overflow or respective owner

Related posts about django

Related posts about test