#33544 closed Cleanup/optimization (fixed)
Hint to default behavior (Deployment checklist > TEMPLATES)
Reported by: | Samuel Hartmann | Owned by: | Samuel Hartmann |
---|---|---|---|
Component: | Documentation | Version: | 4.0 |
Severity: | Normal | Keywords: | deployment checklist, TEMPLATES, DEBUG, documentation, docs |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In the TEMPLATES part of Django's deployment checklist, they say:
Enabling the cached template loader often improves performance drastically
In my understanding this sounds like the cached template loader isn't enabled by default - which I in turn consider misleading.
But in the link to the template loaders docs they explain:
This loader is automatically enabled if OPTIONS['loaders'] isn’t specified and OPTIONS['debug'] is False (the latter option defaults to the value of DEBUG).
which in my understanding means:
"The cached template loader is enabled automatically, if one uses the default Django project settings but(!) with DEBUG being False (which is usually the case on deployment)."
Therefore I suggest to add a hint to TEMPLATES (in the deployment checklist), which points out that the cached template loader is enabled as soon as DEBUG is False.
In practice it could look like this:
Enabling the cached template loader often improves performance drastically, as it avoids compiling each template every time it needs to be rendered.
When DEBUG = False, the cached template loader is enabled.
See the template loaders docs for more information.
This would match the format of the ALLOWED_HOSTS description
When DEBUG = False, Django doesn’t work at all without a suitable value for ALLOWED_HOSTS.
...as well as Performance optimizations
Setting DEBUG = False disables several features that are only useful in development.
If this ticket gets accepted, I would gladly make the adjustments as my first contribution.
Change History (8)
comment:1 by , 3 years ago
Owner: | changed from | to
---|
comment:2 by , 3 years ago
comment:3 by , 3 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 3 years ago
Has patch: | unset |
---|
comment:5 by , 3 years ago
I've created a draft pull request as suggested by Carlton.
The pull request only contains the additional sentence (briefly describing the default behavoir of the cached template loader) in the Deployment checklist, as suggested in the description of the ticket.
I am not at all sure whether I'd be able to enable the cached template loader in development.
But if the changes in the docs are okay like that, I'd suggest to close this ticket here and to create a new ticket for the actual improvement of the cached template loader.
comment:6 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Hi Samuel.
OK, let's accept a clarification on the docs here. Thanks.
Note there was discussion on PR 15140 following from ticket #25791 to enable the cached template loader even in development.
If you wanted to dig-in there, I'd be happy to input too. (It's on my list to investigate...)
Welcome aboard! ⛵️