Thanks a lot Javier! It takes me days to understand this. Hm...what if we don't use Redirect, what will happen in the wire? is it the following? If so, then no re submit problem lor. I must missed something out. <- GET /yourapp/voteform/ -> 200 OK (html with form) <- POST /yourapp/vote (params) -> 200 OK (html with results)
On Sun, Dec 19, 2010 at 7:36 PM, Javier Guerra Giraldez <jav...@guerrag.com>wrote: > On Sat, Dec 18, 2010 at 11:06 AM, Mingming Wang <mingofd...@gmail.com> > wrote: > > From the tutorial of Django, there is the following code in here > > Who knows the mechanism behind a redirect or a direct response? Refer the > > comments below. Thanks a lot! > > HttpResponseRedirect returns a 301 or 302 response code to the > browser, instead of more common 200 (ok), or 404 (not found). That > simply instructs the browser to load the given URL. The interesting > part is that that given URL replaces the original (POST) one in the > browser's history. > > for example, this is what happens on the wire: > > <- GET /yourapp/voteform/ > -> 200 OK (html with form) > <- POST /yourapp/vote (params) > -> 301 Redirect (/yourapp/voteresults/) > <- GET (/yourapp/voteresults/) > -> 200 OK (html with results) > > but this is what gets stored in the history: > > 1: > action: GET /yourapp/voteform/ > cache: html with form (filled) > > 2: > action: GET /yourapp/voteresult/ > cache: html with results > > > see? no traces of the POST. if you hit 'back' in the browser, you go > to the form! the POST ceases to be an event, since from the point of > view of the browser, its only result is to go to the /voteresult/ > page. > > Of course, the user is free to go back and hit the submit button > again, but he's not presented with that cryptic "post again?" dialog. > > -- > Javier > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.