Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialnuri jeon
14,376 PointsI am curious about the difference between httpresponseredirect and render!
Hi :D I have a question. What is the difference between httpresponseredirect and render_to_response? When should I use which?
Thanks!
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsAccording to the docs, render Combines a given template with a given context dictionary and returns an HttpResponse object with that rendered text
, while HttpResponseRedirect returns an HTTP status code 302
[redirect] along with the new URL.
So render
sends back a typical web page, while HttpResponseRedirect
sends back a URL.
Post back if you have more questions! Good luck!!
nuri jeon
14,376 Pointsnuri jeon
14,376 PointsHello! Thank you very much for your help ! :D Hmm so the difference between them is that when you get to use HttpResponse, you're sending the context dictionary with the url so that's rendered as a typical website but if you use HttpResponseRedirect, you get to send only url...? Am I getting this in a right way? :D?.... Thanks for your help again :D
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsCorrect!