HttpResponseRedirect vs render_to_response

149 views
Skip to first unread message

Colin Ma

unread,
May 18, 2014, 3:15:26 PM5/18/14
to django...@googlegroups.com
Hello, I know there are a bunch of threads on this topic (on stacked overflow at least), but I am having trouble understanding something.
In this post:

post  that HttpResponseRedirect should be used. I understand that it may be "cleaner" to do this, but I was wondering how best to pass variables in so the next template/view will have access to it.

I don't want want to pass it in through the URL since users will be typing in a location and I don't want my URL to be like pasadena-california-91006. Is there another way to pass through the information
I want passed on (in this case a simple geographic location such as a city or zip code)? Again, I know I can do it with render, but the linked post suggests otherwise.

The writer of hte post also said that, in the context of render_to_response that it should be used <b> most of the time. <b>

Help would be appreciated, thanks!

Daniel Roseman

unread,
May 18, 2014, 4:41:48 PM5/18/14
to django...@googlegroups.com
Since you were looking on StackOverflow, you should have seen some of the many posts which answer your exact question (Google "Django redirect context" for some examples). TL:DR though: use the session to store your data before redirecting and get it out again from the session in the destination view.
--
DR. 
Reply all
Reply to author
Forward
0 new messages