Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Django Flow

In this lesson, you’ll walk through the flow of a request through a Django app. You’re going to see what happens when you type an address into your web browser and press Enter.

The first address point inside the Django app is the urls.py in the management app. That file will direct you towards the urls.py in the app you want to go to. That will forward you to views.py, where the code logic happens. The functions in there will direct you towards a specific template to render and return to the user to see in the browser.

00:00 In this video, we’ll quickly talk over the flow of a request through a Django app.

00:08 Now, when you’re in your web browser and you type something in there, this is going to be the address of our localhost app. Remember, here on the right, this is the file structure that we just looked at before.

00:20 Now, I want to show you what happens when you type in Enter here. How does the request flow through the Django app to finally present you the website? So, let’s say you click Enter here.

00:33 The next thing that happens is that the first address point for inside the Django app is going to be this urls.py. The project-level management app urls.py that’s defined inside of settings—this is the first one to look at, and it directs us forward to the urls.py inside of our app.

00:54 This one, again, forwards us to views.py, where the code logic happens and the functions in here direct us to a specific template that’s going to get rendered and finally returned back to the user to see in the browser. All right, so, what happens if we change the URL up there?

01:14 Let’s say we want to see a specific project, so I’m typing 1 in here. And again, it goes through the same steps in the process. urls.py, urls.py, views.py, into the templates/, and then the template gets rendered and shown to us, the user on the front end.

01:33 There’s a little bit more to this whole process, and we’re going to dive deeper into it, but just so that you have kind of a connection between what’s happening in the browser and this file structure that we looked at before.

01:46 So, that’s all for a quick overview of the flow inside of a Django project. In the next video, we’re going to do a quick recap of what we talked about in this section of the course, and then we’re going to move on. So, see you in the next video!

lewiuberg on Jan. 9, 2020

Hi! Just wondering, is this the MVC pattern in action? Trying to connect the dots :)

Martin Breuss RP Team on Jan. 10, 2020

@lewiuberg - yes… kind of! :)

Django approaches the MVC topic a bit different than other frameworks, you can read this official answer to a related question.

The basic idea of MVC is to separate different topics (e.g. representation and code logic) into separate areas of your code. And you can see some of that in action when we’re looking at the different parts.

Here’s a nice article that talks some more about it. Hope this helps!

emalfiza on March 17, 2020

@Martin Breuss, a million thanks to this amazing explanation of Djano flow…

Become a Member to join the conversation.