Feature:
Configure name of the templates directory in which the app directory template loader looks for matching template names. Possibly from the template settings.
Current situation:
Currently the directory name ('templates') is hardcoded in the app directory loader (template/loaders/app_directories.py) as a fixed value in a method, thus adjusting it requires a custom class that overrides the method. As django templates default to a configurable file loader (django.template.loaders.filesystem.Loader), I always thought it was odd that the same did not apply to the app directory template loader.
Why I think it's beneficial
Django can support multiple template backends. This can be useful when supporting multiple template situations. I myself like to differentiate my normal front-page templates from my e-mail templates. However, I've run into the issue on three different projects where I could not place a mail template folder in my application folders unless I wrote a custom loader.
I think allowing a loader to have the template folder name as input can allow cleaner code.
What I propose
Essence: Rewrite the app directory template loader to allow the template folder name as input as defined in the
ticket created.
Example template settings:
"OPTIONS": {
"loaders": [
("django.template.loaders.app_directories.Loader", "mail_templates")
],
},
Optional: Rewrite DjangoTemplates to allow dir_name as input to define the directory name for template folders in the applications.
Sources
Let me know if you think this is a good idea. I'd love to hear your opinions :D