# This allows us to use Django's generics with Jinja2, by passing in
# 'template_loader' : jinjaenvironment as part of the dict

# in jinjasupport.py
from django.template.context import Context
import jinja2

class DjangoTemplate(jinja2.Template):
    def render(self, *args, **kwargs):
        if args and isinstance(args[0], Context):
            for d in reversed(args[0].dicts):
                kwargs.update(d)
            args = []
        return super(DjangoTemplate, self).render(*args, **kwargs)

class DjangoEnvironment(jinja2.Environment):
    template_class = DjangoTemplate

jenv = DjangoEnvironment(loader=FileSystemLoader(template_dirs))

# in urls.py - EXAMPLE ONLY
from jinjasupport import jenv

urlpatterns += patterns('django.views.generic.date_based',
  url(r'^photo/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[\-\d\w]+)/$',
      'object_detail',
      {
          'date_field' : 'date_added',
          'slug_field' : 'title_slug',
          'template_loader' : jinjasupport.jenv,
      }, name='pl-photo-detail'),
)