Opened 8 years ago

Closed 8 years ago

#4500 closed (duplicate)

Tutorial: What about the HttpResponseRedirect?

Reported by: anonymous Owned by: jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Can you give an example of what you mean? Since views can be any Python function, "standard views" doesn't mean much.

comment:2 Changed 8 years ago by Mike <mikeshantz@…>

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 Changed 8 years ago by SmileyChris

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of the more verbose ticket #4615

Note: See TracTickets for help on using tickets.
Back to Top