*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
<https://code.djangoproject.com/ticket/33688>.
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*
Ticket: https://code.djangoproject.com/ticket/33688
Github PR: https://github.com/django/django/pull/15676
Let me know if you think this is a good idea. I'd love to hear your
opinions :D
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/f6ab3666-05a7-4839-8c14-a0f23dcc7f63n%40googlegroups.com.