#33688 closed New feature (wontfix)

DjangoTemplates app_dirname does not apply to app directories

Reported by: Dutcher Owned by: Dutcher
Component: Template system Version: 4.0
Severity: Normal Keywords: Templates
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Dutcher)

Each backend defines a conventional name for the subdirectory inside applications where its templates should be stored


The DjangoTemplates class allows for adjusting the name of the folder in which templates are found, but the template loaders do not take this into account. In particular the App Directory Template Loader the folder name ("textures" is currently hardcoded and immutable without writing a custom loader. I think it's better if the code allows for setting the folder name as input upon instance creation:


from .filesystem import Loader as FilesystemLoader

class Loader(FilesystemLoader):
    def __init__(self, engine, dir_name=None):
         self.dir_name = dir_name or "templates"

    def get_dirs(self):
        return get_app_template_dirs(self.dir_name)

Edit: PR availlable: https://github.com/django/django/pull/15676
It is my first PR on django, so feedback is welcome :)

Change History (3)

comment:1 Changed 17 months ago by Dutcher

Description: modified (diff)
Owner: changed from nobody to Dutcher
Status: newassigned

comment:2 Changed 17 months ago by Dutcher

Has patch: set

comment:3 Changed 17 months ago by Mariusz Felisiak

Component: UncategorizedTemplate system
Resolution: wontfix
Status: assignedclosed

Thanks for this ticket, however it looks quite niche and not worth maintaining by Django itself. Creating a small custom loader seems justified in you cannot keep templates in the templates directory.

Please first start a discussion on the DevelopersMailingList (if you don't agree), where you'll reach a wider audience and see what other think, and follow the guidelines with regards to requesting features.

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