Resetting cache for Django cached template loader

后端 未结 4 1254
花落未央
花落未央 2021-01-02 09:23

Django 1.2 introduced a new template loader, that stores data in cache ( django.template.loaders.cached.Loader ).

Unfortunatly, i failed to find any inf

4条回答
  •  鱼传尺愫
    2021-01-02 10:13

    The existing solutions written here broke around Django 1.9, due to the template loader system having been refactored. If you try to use the code that imports template_source_loaders and that import fails, try this:

    from django.template.loader import engines
    
    for engine in engines.all():
        engine.engine.template_loaders[0].reset()
    

    This code assumes that your TEMPLATES setting is using the default 'loaders' option, or using only a single django.template.loaders.cached.Loader.

提交回复
热议问题