views:

376

answers:

1

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?

+1  A: 

This is a bug in Django trunk that was recently fixed.

Carl Meyer
@Carl, it's helpful. thanks.
jack