开发者

AttributeError: 'search' object has no attribute 'status_code' in django project

开发者 https://www.devze.com 2023-02-21 23:50 出处:网络
I\'m testing a django project using the test sever when it gives me the following exception Traceback (most recent call last):

I'm testing a django project using the test sever when it gives me the following exception

Traceback (most recent call last):

File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 280, in run self.result = application(s开发者_StackOverflow社区elf.environ, self.start_response)

File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 674, in >call return self.application(environ, start_response)

File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py", line 245, in call response = middleware_method(request, response)

File "/usr/lib/pymodules/python2.6/django/middleware/common.py", line 84, in >process_response if response.status_code == 404:

AttributeError: 'search' object has no attribute 'status_code'

Just from reading this traceback, I don't think the problem is in my code, but I'm not sure. Could someone look through my code and help me solve this problem? my code is hosted on GitHub and any other comments or suggestions are greatly appreciated. Thanks in advance for your time and consideration.


MusicGrep/musicgrep/views.py is not returning a HttpResponse instance


There are quite a few problems with your code, but the one that's causing the actual error you quote is that you don't instantiate your FormWizard subclass in your urlconf.

As the documentation shows, you need to actually call the search class in urls.py to instantiate it, so you pass an instance rather than a class.

(r'^MusicGrep/$', 'MusicGrep.musicgrep.forms.search()'),

It might help if you followed the PEP8 guidelines on naming - if your class was called Search with a capital S, it would be more obvious that it was actually a class and not a function.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号