Opened 16 years ago
Last modified 16 years ago
#7768 closed
HttpResponseRedirect causes a TypeError 'str' object is not callable in base.py — at Version 2
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Working with SVN revision 7930, following the tutorial, up to the place where the votes view is created.
The line in the vote() method
return HttpResponseRedirect(reverse('mysite.polls.views.results', args=(p.id,)))
fails presenting a debug page that says:
TypeError at /polls/1/results/ 'str' object is not callable Request Method: GET Request URL: http://127.0.0.1:8000/polls/1/results/ Exception Type: TypeError Exception Value: 'str' object is not callable Exception Location: C:\Python25\lib\site-packages\django\core\handlers\base.py in get_response, line 85
I have found some relates issues (like 4700) that point to the INSTALLED_APPS settings and how the django.contrib.auth affects the get_response. I tried eliminating that application and still the error shows.
If using HttpResponseRedirect without the reverse (hardcoding the url) it fails too. If using render_to_response() instead, it works.
Another relate ticket may be 6442, but that one happens when the import error occurs. In this case the imports are ok in views.py, it is the HttpResponseRedirect that may have problems.
William Martinez.
An update.
I found out a problem in the views.py, the actual results() method that is the one called when HttpResponseRedirect is executed (url is '/polls/3/results/'). It had a problem in the name, so it was not found. That may not cause an import issue like in ticket 6442 but it will probably raise an exception. I was about to set this ticket as a duplicaet of 6442, but it is slightly different in the cause. Still, it may be resolved around the same command line.
Here, as in 6442, the error should indicate the view was not found instead of the misleading TypeError at base.py.
William.