Re: Tutorial: rerender or redirect questions
On Aug 8, 3:32 pm, Rodney Topor <r.to...@gmail.com> wrote:
> I have a question about the definition of function vote in part 4 of
> the tutorial.
>
> If the user presses the button Vote without selecting a choice, this
> function renders the template polls/detail.html to redisplay the poll
> detail with an error message. However, the URL in the address bar of
> the browser still shows /polls/n/vote/. In the RESTful spirit of
> things,
Remember that in this case you are POSTing to /polls/n/vote.
> assuming URLs are important, I think the address bar should
> now show /polls/n/, as we are simply displaying the poll detail page
> not processing a vote.
Fail ;) We ARE processing a vote - or, more exactly, displaying the
failed result of the processing.
> This would seem to require a redirect to /
> polls/n/ instead of a rerendering of polls/detail.html.
Which requires transmitting the whole error message stuff, either
using a session or - even worse - encoding them in the quesrystring.
This is a major PITA and a total waste of resources, for zero
practical benefit. Redisplaying the form with an error message when
the processing failed on user input validation (and only redirecting
on success) is the standard way of doing things.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home