How do I expire a django template cache key on receiving a signal?

后端 未结 3 1915
一生所求
一生所求 2021-02-06 10:25

In my front page template I use the cache function like this:

{% cache 86400 my_posts %}
    {% get_latest_posts %}
{% endcache %}

When there i

3条回答
  •  太阳男子
    2021-02-06 11:04

    from django.core.cache import cache
    from django.core.cache.utils import make_template_fragment_key
    
    cache.delete(make_template_fragment_key('footer'))
    

提交回复
热议问题