4.5.2 Filling in Content with Template Variables
The HTML comments in our template would be very helpful to a human, but Django needs a little bit more help figuring out what to fill in. With (most) templates, we must assume we will give Django at least one object with a name of our choosing (we do so in Chapter 5). Django uses such objects to fill in the blanks left in the template. In this instance, we want to supply Django with tag information. We therefore plan to give the template we are currently building a Tag
model object, creatively named tag
. In Django nomenclature, we pass a Tag
instance to the tag
template variable.
Django templates allow us to handle Python objects just as we would in Python via a domain-specific language. Practically ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.