Ticket #4409: 4409.patch
File 4409.patch, 1.7 KB (added by , 17 years ago) |
---|
-
docs/tutorial04.txt
67 67 # Always return an HttpResponseRedirect after successfully dealing 68 68 # with POST data. This prevents data from being posted twice if a 69 69 # user hits the Back button. 70 return HttpResponseRedirect(reverse( 'results', args=(p.id,)))70 return HttpResponseRedirect(reverse(results, args=(p.id,))) 71 71 72 72 This code includes a few things we haven't covered yet in this tutorial: 73 73 … … 96 96 97 97 * We are using the ``reverse()`` function in the ``HttpResponseRedirect`` 98 98 constructor in this example. This function helps avoid having to 99 hardcode a URL in the view function. It is given the name of the view100 t hat we want to pass control to and the variable portion of the URL101 p attern that points to that view. In this case, using the URLConf we set102 up inTutorial 3, this ``reverse()`` call will return a string like ::99 hardcode a URL in the view function. It is given the view that we want 100 to pass control to and the variable portion of the URL pattern that 101 points to that view. In this case, using the URLConf we set up in 102 Tutorial 3, this ``reverse()`` call will return a string like :: 103 103 104 104 '/polls/3/results/' 105 105 106 106 ... where the ``3`` is the value of ``p.id``. This redirected URL will 107 then call the `` 'results'`` view to display the final page.107 then call the ``results`` view to display the final page. 108 108 109 109 For more information about ``reverse()``, see the `URL dispatcher`_ 110 110 documentation.