Template block
A template block is a named region in a template that a child template can fill or override.
The Well-Grounded Python Developer: How the pros use Python and Flask
A template block is a named region in a Jinja2 template that can be defined by a parent and filled or overridden by a child.
- How it is used
- Organizes shared Flask page layout and page-specific content through parent and child Jinja2 templates.
- How deep it goes
- Defines block syntax and demonstrates parent and child templates, without detailing template-rendering internals.
- Examples
- Uses a shared page template and a child displaying time, visit counts, and banner colors.
- What you can do after
- Build it from scratch: separate shared page structure from content supplied by a child template.
Django in Action
A template block is a named section of a template delimited by paired template tags that can be replaced by a child template.
- How it is used
- Composes reusable Django pages by centralizing shared HTML and replacing named sections in child templates.
- How deep it goes
- Defines block syntax, inheritance, named closing tags, block.super, and a working view-template update.
- Examples
- Uses RiffMates base.html and news2.html to demonstrate title and content overrides, loops, and inherited content.
- What you can do after
- Apply Django template inheritance to build shorter pages that share structure and site-wide styling.
Related concepts
- templatepart of · A template is a reusable structure with fixed elements and variable parts for creating or generating similar content, outputs, or artifacts.
- blockkind of · A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

