Created
November 11, 2011 20:06
-
-
Save mdippery/1359075 to your computer and use it in GitHub Desktop.
Creates a template cache key for Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils.hashcompat import md5_constructor | |
from django.utils.http import urlquote | |
def template_cache_key(fragment_name, *vary_on): | |
"""Builds a cache key for a template fragment. | |
This is shamelessly stolen from Django core. | |
""" | |
base_cache_key = "template.cache.%s" % fragment_name | |
args = md5_constructor(u":".join([urlquote(var) for var in vary_on])) | |
return "%s.%s" % (base_cache_key, args.hexdigest()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment