Задать вопрос

Тел: +7 965 3737 888

394

Просмотров

2

Ответов

invalidation of cache-template-tag cache

this function invalidates a template-fragment cache bit.

say you have:

{% load cache %} {% cache 600 user_cache user.id %} something expensive here {% endcache %}

maybe you want to force an update. With this function you can, just call:

invalidate_template_cache("user_cache", user.id)

Вопрос полезен? Да0/Нет0
file_3712.py(411.0б)
None

Ответы (2):

Ответtedtieken:18.12.2011
Ответ полезен? Да0/Нет0

https://github.com/tedtieken/django-template-reset-cache

Wraps the invalidation function in a template tag.

Ответwiggins:07.09.2009
Ответ полезен? Да0/Нет0

This didn't work for me on django1.1,

The following did though:

def invalidate_template_cache(fragment_name, *variables):
  args = md5_constructor(u':'.join([urlquote(var) for var in variables]))
  cache_key = 'template.cache.%s.%s' % (fragment_name, args.hexdigest())
  cache.delete(cache_key)