Created
March 13, 2015 22:23
-
-
Save balazs-endresz/592913a3f425509d3a51 to your computer and use it in GitHub Desktop.
invalidate cached template fragments (tested with django 1.5 only)
This file contains hidden or 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.core.cache import cache | |
from django.utils.hashcompat import md5_constructor | |
from django.utils.http import urlquote | |
def invalidate_template_fragment(fragment_name, *variables): | |
args = md5_constructor(u':'.join([urlquote(var) for var in variables])) | |
cache_key = 'template.cache.{0}.{1}'.format(fragment_name, args.hexdigest()) | |
cache.delete(cache_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment