Skip to content

Instantly share code, notes, and snippets.

@monolithed
Created February 26, 2013 18:51
Show Gist options
  • Save monolithed/5041011 to your computer and use it in GitHub Desktop.
Save monolithed/5041011 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.template import loader
from django.conf import settings
template_cache = {}
original_get_template = loader.get_template
def cached_get_template(template_name):
global template_cache
t = template_cache.get(template_name,None)
if not t or settings.DEBUG:
template_cache[template_name] = t = original_get_template(template_name)
return t
loader.get_template = cached_get_template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment