import django.template.loader as djloader from django.template.loader import get_template as _original_get_template def context_to_dict(ctxt): res={} for d in reversed(ctxt.dicts): res.update(d) return res class Jinja2Template(object): def __init__(self, template_obj): self.template_obj=template_obj def render(self, context): return self.template_obj.render(context_to_dict(context)) def get_template(template_name): source, origin = djloader.find_template_source(template_name) #, dirs #logging.debug(origin.name) for skip_path in getattr(settings, 'KEEP_DJANGO_TEMPLATES', ()): if skip_path in origin.name: return _original_get_template(template_name) template = env.from_string(source) template.name = template_name return Jinja2Template(template) djloader.get_template = get_template