Opened 17 years ago
Closed 17 years ago
#4500 closed (duplicate)
Tutorial: What about the HttpResponseRedirect?
Reported by: | anonymous | Owned by: | Jacob |
---|---|---|---|
Component: | Documentation | 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
In the Tutorial it is not explained how to replace the final:
HttpResponseRedirect(reverse('mysite.polls.views.results', args=(p.id,)))
in order to fit to the standard views of Django ;-)
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
I noticed this as well.
I think what is meant is the following:
The text in tutorial04 (http://www.djangoproject.com/documentation/tutorial04/) needs a bit of an update.
In part 4 of the tutorial the /polls/urls.py file is updated to "use generic views" (last section). This is being changed from the setup that was explained in part 3 (http://www.djangoproject.com/documentation/tutorial03/).
Earlier in part 4 a view function called vote() is created. In this function there is a reverse lookup of a url using the setup from from part 3. The line is return HttpResponseRedirect(reverse('mysite.polls.views.results', args=(p.id,)))
.
When, in part 4, you are instructed on updating the vote() function to match the new "generic views" setup, there is no instruction for changing this line. The problem is that no url has been configured for the reverse lookup to get, and so pressing the vote button on http://localhost:8000/polls/1/vote/ yeilds a "NoReverseMatch at /polls/1/vote/" error.
comment:3 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Dupe of the more verbose ticket #4615
Can you give an example of what you mean? Since views can be any Python function, "standard views" doesn't mean much.