Django: Getting Started Transcripts
Chapter: Introducing the Django Web Framework
Lecture: HTML template engine

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The original writers of the Django framework were coders working at a newspaper.
0:05 They had a strong desire to separate out the business logic from the presentation, particularly because they had an HTML design staff.
0:12 They wanted it to be simple for those design folks to do some coding like things but without having to know how to write Python.
0:20 A big part of this is the template rendering engine. It isn't HTML specific, but a generic mechanism for template text.
0:28 HTML is the typical use, but you may also use it for formatting an email the system is sending out or any other text presentation you might want to do.
0:38 The template engine has its own mini language comprised of tags and filters.
0:44 The tags are placeholders that are replaced with content and depending on the tag, do different things.
0:49 Out of the box Django comes with control flow tags that allow you to do four loops like repetition and if statement like conditionals.
0:57 You can also reuse your content by creating blocks, inheriting them or including them in the document.
1:05 Or you can render data sent into the template engine as variables, through the data context. The other part of the mini language is filters.
1:14 Filters work inside of tags that render variables and act as data presentation modifiers. They change how the variable is rendered.
1:23 For example, the filter might take a date object and present it as the appropriately localized shortform for a date.

Talk Python's Mastodon Michael Kennedy's Mastodon