Inheritance and Escaping
One layout, many pages. A base template defines the shape of the site and leaves named blocks empty. Each page extends it and fills the blocks in.
{% extends %} must be the first tag in the file. Anything a child template puts outside a block is discarded, silently, which is a surprising amount of missing content the first time it happens.
Escaping is on by default, and it is a security feature. Django escapes HTML in values before printing them. That is what stops a comment containing a script tag from becoming a script tag.
|safe switches it off for that value. Use it only on content you generated. Never on anything a person typed. If users must be allowed some HTML, sanitize it on the way in with a library built for that, rather than trusting it on the way out.
Where templates live. app/templates/app/name.html. The app name appears twice, and that is deliberate: template directories are searched in order and merged, so the inner folder is what stops two apps' index.html from colliding.
TemplateDoesNotExist almost always means that nesting is missing, or the app is not in INSTALLED_APPS so its template folder is not searched at all.
Mark this lesson complete
Signed in, your progress follows you to every device.