Monday, January 31, 2011

Re: Redirect with current data

On 2011-01-31, at 06:36 , Antônio Ribeiro wrote:
> Hello guys!
>
> I've been wondering about this all night and i've already made a search on
> google and everything, but I didn't get a straight answer.
>
> Is there a way to make a redirect and send data from my current request to
> the other page.
>
> I mean, I could use the render_to_response to call another template and
> render the content I want.
> But I just want to know if it's possible to redirect to other view with the
> data coming from the current request.
>
Depends what you mean by "data". You're not very clear on that. If it's GET data, then it's trivial, just create the new URL with the data set as url parameters and you're done. If you want to POST a redirect, then things are more tricky: original HTTP semantics don't support POST redirects, not without warning the UA.

> I know it's odd, but this would send a 302 HTTP code to the User-Agent, I
> think that would be the right way.
Nope. HTTP 302 is generally implemented using HTTP 303 semantics ("See Other", which mandates GETing the Location uri). What you want is a 307 redirect (Temporary Redirect, the original meaning for 302 but not the way it was generally implemented), which will reissue the request using the same method (POST if the original was POST) but should warn the user.

Though I don't know if the POST payload will be carried through. I'd expect it, but considering Firefox drops all request headers on a redirect it wouldn't surprise me if it dropped the request body as well.

--
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.

No comments:

Post a Comment