Opened 5 years ago
Closed 5 years ago
#30919 closed New feature (wontfix)
Template-loader postmortem should list non-existent directories.
Reported by: | instantname | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
With debug on, when a template is not found, the "template-loader postmortem" shown in the TemplateDoesNotExist error page seems to only list search directories that exist on the filesystem (see example below). In my opinion, it would make more sense to display all the directories searched, even if they do not exist. Reasons are:
- It is easier to figure out how changing the templates settings changes what paths searched.
- Hiding non-existing searched directories makes misconfigurations more likely as developers may not be aware of all the paths that are searched.
I have tested on the example below. Maybe this also happens in other cases.
settings.py:
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS: [], 'APP_DIRS': True, ... } ] INSTALLED_APPS = [ 'my_app', ... ]
If the directory /.../my_project/my_app/templates exists and is empty, requesting the non-existent 'my_app/index.html' template gives this debug log:
Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.app_directories.Loader: /var/local/my_project/my_app/templates/my_app/index.html (Source does not exist) [... other things ...]
But if the directory /.../my_project/my_app/templates does not exist, that search path disappears from the list of searched paths in the TemplateDoesNotExist traceback:
Template-loader postmortem Django tried loading these templates, in this order: Using engine django: [... only the other things ...]
Change History (1)
comment:1 by , 5 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Summary: | Template-loader postmortem should list non-existent directories → Template-loader postmortem should list non-existent directories. |
Type: | Bug → New feature |
Version: | 2.2 → master |
Thanks for this ticket, but IMO it will be more confusing and incorrect to display a list of non-existent apps' directories. Loaders skip them, so it is incorrect to say they were used to find a missing template, moreover users may falsely assume that they exist.