Django 1.2 引入了一个新的模板加载器,它将数据存储在缓存中(django.template.loaders.cached.Loader
).
不幸的是,我未能找到有关缓存如何失效以及何时以及如何重置的任何信息。
我想在我的服务器上使用它,但我不确定它是否会在 django 重新启动时重置(这对我来说就足够了)。
from django.template.loader import template_source_loaders
def reset_template_cache():
if not template_source_loaders:
return
for loader in template_source_loaders:
loader.reset()
就这样吧:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)