I am using class-based views and I would like to avoid typing full paths for the template_name. By default, Django searches for templates in templates/english (english is the name of my app), but I would like it to also search in subdirectories. How can I do that?
in template:
{% load static %}
...
<img src="{% static 'english/subdirectory/image.png'%}">
You misunderstood me, I want my class based views to know to search for templates also in subdirectories to avoid typing the full paths of these templates in the template_name attribute
oh. I’ve always specified full paths on CBvs. The paths are usually not long
template_name = "english/page.html"
that should do it. No need to specify the template root
That would be an extremely bad idea in the context of how Django works.
Keep in mind that Django will search through all directories specified in the TEMPLATES setting not just the directory for the current app. It’s this feature that allows an app to override the templates being used by other apps. So in that sense, the directory names form a namespace for templates to be organized and identified by app or as a feature within an app.