Django Redirects (Overview)
When you build web applications in Python using the Django framework, you’ll likely need to redirect the user from one URL to another. This course covers what you need to know about redirecting in Django. All the way from the low-level details of the HTTP protocol to the high-level way of dealing with them in Django.
By the end of this course, you’ll learn:
- How HTTP Redirects work
- The difference between temporary and permanent redirects
- How to use query strings with a redirect
- How to avoid common problems
00:00 Welcome to Django Redirects. My name is Chris and I will be your guide. In this course, I’ll be talking about how to do an HTTP redirect inside of Django.
00:09
First off, I’ll cover just what an HTTP redirect is, how to use Django’s redirect()
shortcut, how to use Django’s RedirectView
class helper, what to do if your redirects require parameters, and finally, those corner cases and caveats.
00:25 The code in this course was created using Django 3.0 and Python 3.8. Most of the content should apply to earlier versions. Django 2 and Django 3 are fairly compatible. There’s one small exception, which I’ll mention in later lessons.
00:38 If you use anything earlier than Django 2, you will run into problems in that the URL pathing structure changed between late versions of Django 1 and Django 2.
00:47
Almost all of the code examples shown throughout here are found inside of a Django project called Redirector
, which is available for download inside of the description.
00:56 Feel free to download it and follow along as I talk about each section.
01:00 This course assumes familiarity with Django views and URL patterns. If you need to review this content, view the prologue for a refresher or visit some of the links in the description.
Become a Member to join the conversation.