This wraps up this guide on HTTP redirects with Django. Congratulations: you have now touched on every aspect of redirects all the way from the low-level details of the HTTP protocol to the high-level way of dealing with them in Django.
You learned how an HTTP redirect looks under the hood, what the different status codes are, and how permanent and temporary redirects differ. This knowledge is not specific to Django and is valuable for web development in any language.
You can now perform a redirect with Django, either by using the redirect response classes HttpResponseRedirect
and HttpResponsePermanentRedirect
, or with the convenience function django.shortcuts.redirect()
. You saw solutions for a couple of advanced use cases and know how to steer clear of common pitfalls.
Here are resources for more information on Django redirects and HTTP redirects: