Skip to content

Entries published on November 1, 2007

1 entry published on this date. See also: all entries published in November 2007, full archive.

Django tips: template loading and rendering

I’ve been reminded today by Maura that November is National Blog Posting Month, when — in theory — bloggers the world over try to keep up a pace of one entry every day. I don’t know how well this is going to go, but I’d like to give it a try. And, inspired by Drew McLellan’s excellent 24 ways “advent calendars” of web-design tips, I’m going to give it a theme: one Django tip every day during the month of November. Kicking off the series, I’d like to focus today on the deceptively-simple task of template loading and rendering.

The long way

If you’ve ever read through the Django tutorial, you know that manually loading and rendering a template is a bit of a chore, because it involves multiple separate steps. The canonical example looks like this:

from django.template import loader, Context

t = loader.get_template('my_template.html')
c …

Entry published November 1, 2007. Read full entry.