mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #33639 -- Enabled cached template loader in development.
This commit is contained in:
parent
f4f2afeb45
commit
bf7c51a5f4
4 changed files with 48 additions and 32 deletions
|
@ -99,9 +99,14 @@ overridden by what's passed by
|
|||
* ``'django.template.loaders.app_directories.Loader'`` if and only if
|
||||
``app_dirs`` is ``True``.
|
||||
|
||||
If ``debug`` is ``False``, these loaders are wrapped in
|
||||
These loaders are then wrapped in
|
||||
:class:`django.template.loaders.cached.Loader`.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
In older versions, the cached template loader was only enabled by
|
||||
default when ``DEBUG`` was ``False``.
|
||||
|
||||
See :ref:`template-loaders` for details.
|
||||
|
||||
* ``string_if_invalid`` is the output, as a string, that the template
|
||||
|
@ -905,10 +910,9 @@ loaders that come with Django:
|
|||
|
||||
.. class:: cached.Loader
|
||||
|
||||
By default (when :setting:`DEBUG` is ``True``), the template system reads
|
||||
and compiles your templates every time they're rendered. While the Django
|
||||
template system is quite fast, the overhead from reading and compiling
|
||||
templates can add up.
|
||||
While the Django template system is quite fast, if it needs to read and
|
||||
compile your templates every time they're rendered, the overhead from that
|
||||
can add up.
|
||||
|
||||
You configure the cached template loader with a list of other loaders that
|
||||
it should wrap. The wrapped loaders are used to locate unknown templates
|
||||
|
@ -917,11 +921,9 @@ loaders that come with Django:
|
|||
subsequent requests to load the same template.
|
||||
|
||||
This loader is automatically enabled if :setting:`OPTIONS['loaders']
|
||||
<TEMPLATES-OPTIONS>` isn't specified and :setting:`OPTIONS['debug']
|
||||
<TEMPLATES-OPTIONS>` is ``False`` (the latter option defaults to the value
|
||||
of :setting:`DEBUG`).
|
||||
<TEMPLATES-OPTIONS>` isn't specified.
|
||||
|
||||
You can also enable template caching with some custom template loaders
|
||||
You can manually specify template caching with some custom template loaders
|
||||
using settings like this::
|
||||
|
||||
TEMPLATES = [{
|
||||
|
@ -947,6 +949,12 @@ loaders that come with Django:
|
|||
information, see :ref:`template tag thread safety considerations
|
||||
<template_tag_thread_safety>`.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
The cached template loader was enabled whenever ``OPTIONS['loaders']``
|
||||
is not specified. Previously it was only enabled when ``DEBUG`` was
|
||||
``False``.
|
||||
|
||||
``django.template.loaders.locmem.Loader``
|
||||
|
||||
.. class:: locmem.Loader
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue