Module 04 of 12

Templates & Static Files

Lessons

About This Module

A view decides what data to show; a template decides how it looks. Django's template language lets you write ordinary HTML and drop in variables, tags for loops and conditions, and filters that format values, all without putting Python logic into your markup. Keeping presentation separate from view code is what makes a project easier to read and change.

In this module you will learn how Django finds templates, how a view passes context to them, and how template inheritance lets you build one base layout with {% block %} sections that every page extends, so you never repeat headers, navigation, or footers. You will then learn how to serve static files such as CSS, JavaScript, and images using STATIC_URL, STATICFILES_DIRS, and the {% static %} tag.

Watch the lessons in order, then continue on to Models & the ORM. Some of these videos were recorded on older Django releases, so check the official documentation if a detail differs on your install.

Lessons

4 videos
01

Python Django Tutorial: Full-Featured Web App Part 3 - Templates

Corey Schafer shows how to return richer HTML with templates, pass variables from a view into a template, and use template tags and inheritance to avoid repeating markup.

02

Django Tutorial - Templates & Custom HTML

Tech With Tim covers creating and extending templates, using variables and content blocks, and looping and conditional statements for dynamic HTML.

03

Django Tutorial #12 - Static Files & Images

The Net Ninja sets up a project to serve static files such as images, CSS, and JavaScript, and shows how to load and reference them from a template with the static tag.

04

Configure Static & Media Files in Django

Walks through the static files settings, including STATIC_URL, STATICFILES_DIRS, and the static template tag, plus serving uploaded media files during development.