Opened 4 months ago

Closed 3 months ago

Last modified 3 months ago

#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 Changed 4 months ago by Samuel Hartmann

Owner: changed from Samuel Hartmann to Samuel Hartmann

comment:2 Changed 4 months ago by Carlton Gibson

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! ⛵️

comment:3 Changed 4 months ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

comment:4 Changed 4 months ago by Mariusz Felisiak

Has patch: unset

comment:5 Changed 3 months ago by Samuel Hartmann

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 Changed 3 months ago by Carlton Gibson

Triage Stage: AcceptedReady for checkin

comment:7 Changed 3 months ago by Carlton Gibson <carlton@…>

Resolution: fixed
Status: assignedclosed

In 5cc9464e:

Fixed #33544 -- Expanded the TEMPLATES section of the Deployment checklist.

Clarified that the cached template loader is enabled by default when
DEBUG = False.

comment:8 Changed 3 months ago by Carlton Gibson <carlton.gibson@…>

In 280661b:

[4.0.x] Fixed #33544 -- Expanded the TEMPLATES section of the Deployment checklist.

Clarified that the cached template loader is enabled by default when
DEBUG = False.

Backport of 5cc9464e4d8fe2762e462560665fd1f28104bbca from main

Note: See TracTickets for help on using tickets.
Back to Top