[Django] #32644: TemplateDoesNotExist for templates in local apps

24 views
Skip to first unread message

Django

unread,
Apr 13, 2021, 7:39:52 AM4/13/21
to django-...@googlegroups.com
#32644: TemplateDoesNotExist for templates in local apps
-------------------------------------------+------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Ok, I do hope this one is a valid bug ticket!

Since the update from 3.1.8 to 3.2 I get a `TemplateDoesNotExist` error
for alle templates **not living in the main template folder** but within
my local apps.

Project structure:

Apps live under: myproject/apps/
Main template dir: myproject/templates
Templates for an app live under: myproject/apps/myapp/templates

My config:
{{{
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
}}}

When I run my tests under 3.1.8, it works. When I update to 3.2 and run
them, it throws the `TemplateDoesNotExist` exceptions.

I'd be happy to assist in any way possible.

--
Ticket URL: <https://code.djangoproject.com/ticket/32644>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 13, 2021, 9:32:14 AM4/13/21
to django-...@googlegroups.com
#32644: TemplateDoesNotExist for templates in local apps
---------------------------------+--------------------------------------

Reporter: Ron | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham):

I think the issue is that `DIRS` isn't an absolute path. If that worked in
previous versions, it was probably only by chance.

--
Ticket URL: <https://code.djangoproject.com/ticket/32644#comment:1>

Django

unread,
Apr 13, 2021, 2:56:53 PM4/13/21
to django-...@googlegroups.com
#32644: TemplateDoesNotExist for templates in local apps
---------------------------------+--------------------------------------
Reporter: Ron | Owner: nobody
Type: Bug | Status: closed

Component: Template system | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Yes, `DIRS` should contain full paths as
[https://docs.djangoproject.com/en/3.2/ref/templates/api/#the-dirs-option
documented], so in your case `'DIRS': [BASE_DIR / 'templates']`. It works
for me with the described project structure. Please use one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels] if you still have an issue with templates.

--
Ticket URL: <https://code.djangoproject.com/ticket/32644#comment:2>

Reply all
Reply to author
Forward
0 new messages