[Django] #25061: Default template loader wrong in docs OR default loader not working properly

4 views
Skip to first unread message

Django

unread,
Jul 3, 2015, 8:08:59 PM7/3/15
to django-...@googlegroups.com
#25061: Default template loader wrong in docs OR default loader not working
properly
---------------------------------+-----------------------------------------
Reporter: mlissner | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8
Severity: Normal | Keywords: loader, templates, defaults
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+-----------------------------------------
Not sure if the docs are correct or if the functionality is incorrect. In
any case, the docs say that in Django 1.8, the default template loaders
are:

('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader')

The error I ran into was that when I had the TEMPLATES variable set,
Django could not find the templates from the debug toolbar, which made me
think that the app_directories loader wasn't working.

I did three tests:

First, I added the above tuple to the TEMPLATES directory to see if the
default wasn't being set correctly. When I added the values above,
suddenly the template was found successfully.

Second, I created a brand new project in a brand new virtualenv. In the
env I installed django_debug_toolbar and django 1.8.2. I then added
debug_toolbar to the installed apps, and tested if runserver could find
the templates it needed to. Sure enough, this worked.

Third, when that worked, I noticed that the default settings for Django
1.8.2 still use the TEMPLATE_ format. This seems odd (perhaps an indicator
that my system wasn't clean?) but I swapped the settings over to use the
TEMPLATES variable instead. Again, when 'loaders' is unset, the template
can't be found, but when it is set to the supposed default value, things
work fine.

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

Django

unread,
Jul 3, 2015, 8:18:55 PM7/3/15
to django-...@googlegroups.com
#25061: Default template loader wrong in docs OR default loader not working
properly
-------------------------------------+-------------------------------------

Reporter: mlissner | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8
Severity: Normal | Resolution:
Keywords: loader, templates, | Triage Stage:
defaults | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Which docs are you referring to regarding the template loaders defaults?
Is it from the [https://docs.djangoproject.com/en/dev/ref/settings
/#template-loaders TEMPLATE_LOADERS] setting? If so, I think the confusion
is that once you define the `TEMPLATES` setting, the old `TEMPLATE_`
settings are ignored.

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

Django

unread,
Jul 3, 2015, 8:28:52 PM7/3/15
to django-...@googlegroups.com
#25061: Default template loader wrong in docs OR default loader not working
properly
-------------------------------------+-------------------------------------
Reporter: mlissner | Owner: nobody
Type: Bug | Status: closed

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

Keywords: loader, templates, | Triage Stage:
defaults | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by carljm):

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


Comment:

As best I can figure out, OP is either referring to what you linked, or to
the mention of "the default value of TEMPLATE_LOADERS" in
https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/#the-
templates-settings

Both of those are referring to the default value of `TEMPLATE_LOADERS`
pre-1.8. The default value of `['OPTIONS']['loaders']` for Django Template
Language in 1.8 is more complex; it only includes the `app_directories`
loader if you set `APP_DIRS: True`, as documented in the TEMPLATES setting
docs: https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-
TEMPLATES

I would assume the OP isn't setting `APP_DIRS: True`. It defaults to
`False`, though the startproject default settings file sets it to `True`.

But it sounds like OP also has a polluted installation of 1.8 which is
somehow still using an old project template. Django 1.8 startproject
template definitely uses `TEMPLATES`, not `TEMPLATE_*`.

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

Django

unread,
Jul 3, 2015, 8:37:25 PM7/3/15
to django-...@googlegroups.com
#25061: Default template loader wrong in docs OR default loader not working
properly
-------------------------------------+-------------------------------------
Reporter: mlissner | Owner: nobody
Type: Bug | Status: closed

Component: Template system | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: loader, templates, | Triage Stage:
defaults | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by mlissner):

Yeah, I think it's safe to close this off. I thought that the old
TEMPLATE_* settings were mapped more or less directly to the new OPTIONS
key...missed that it's {} by default.

End of day Friday. Apologies.

--
Ticket URL: <https://code.djangoproject.com/ticket/25061#comment:3>

Reply all
Reply to author
Forward
0 new messages