Django: Getting Started Transcripts
Chapter: Introducing the Django Web Framework
Lecture: Visualizing how Django works

Login or purchase this course to watch this video and the rest of the course contents.
0:00 You're sitting at home and you suddenly have a desire to look up your next good read.
0:06 You type in the URL of your favorite Django based book site and you get back a list of books. Just how does that happen? Well, let's take a look.
0:17 Your browser looks at the host name part of the URL And uses that to contact a server.
0:25 That server sees the whole address and uses it to make a decision. In the case of Django a routing manager looks at the address,
0:33 particularly the stuff after the host name and makes a decision based on a giant URL map. That map points to some code or if it doesn't
0:44 points to some code that handles what to do. If the URL isn't found. This code in Django is called a view.
0:52 When I write a view, I tend to call it something very close to the URL. It doesn't have to be but it makes finding stuff easier
0:58 So the book listing part of the URL maps to the book listing view where some code is run. That code creates a list of books from the database.
1:11 Then builds a data context which is a special dictionary, uses that context to call a template engine that is responsible for rendering a template.
1:21 In this case some HTML.
22:02 That rendering would include things like looping through all the books that are in the context and putting them inside of an HTML unordered list
1:31 The template engine returns the result to the view. The view wraps the result in an HTTP-response object,
1:40 the kind of object Django expects all views to return and then returns it. Django takes that response object and forms the body of the HTTP-response,
1:51 passing it down to the Web server, and the web server then returns the whole thing to your browser. For quick sites all this happens in under a second
2:01 and you get to choose which book you're going to read next. Let's talk a little more about each one of these pieces and what Django does for you.

Talk Python's Mastodon Michael Kennedy's Mastodon