This is the quickest way I've found to bootstrap Django templates without using the entire framework. This is suited for "plain-python" apps without using all the Django types. You'll probably want to cache the Template returns for each given name, but here's the basics.
1
2
3 from django.conf import settings
4 settings.configure(TEMPLATE_DIRS=("/whatever/templates",))
5
6 import django.template
7 import django.template.loader
8
9
10 def render(name, *values):
11 ctx = django.template.Context()
12 for d in values:
13 ctx.push()
14 ctx.update(d)
15
16 t = django.template.loader.get_template(name)
17 return t.render(ctx)
18
19 print render('layout.tmpl', dict(title='User'), dict(name='Bob', gender='M'))