summaryrefslogtreecommitdiff
path: root/django/core/cache/utils.py
blob: d41960f6e47f74f411f9b76adb8a0fe01aac80ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
from django.utils.crypto import md5

TEMPLATE_FRAGMENT_KEY_TEMPLATE = 'template.cache.%s.%s'


def make_template_fragment_key(fragment_name, vary_on=None):
    hasher = md5(usedforsecurity=False)
    if vary_on is not None:
        for arg in vary_on:
            hasher.update(str(arg).encode())
            hasher.update(b':')
    return TEMPLATE_FRAGMENT_KEY_TEMPLATE % (fragment_name, hasher.hexdigest())