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 trial

Python Django Forms Forms Custom Field Validation

nuri jeon
nuri jeon
14,376 Points

I 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
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

According 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
nuri jeon
14,376 Points

Hello! 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