However, `TEMPLATES` is created automatically by the default project
template; and in this case Django does not use the value in
`TEMPLATE_DIRS`. This means that users following pre-1.8 tutorials (for
example, the very popular Tango with Django) will be instructed to add
`TEMPLATE_DIRS` to a settings file that ignores that value, and then will
be surprised that their templates are not found. This has hit quite a few
users on StackOverflow, for example:
http://stackoverflow.com/questions/31108314/templatedoesnotexist-error-in-
django/31109213
http://stackoverflow.com/questions/30844500/django-templatedoesnotexist-
error-on-windows-machine
http://stackoverflow.com/questions/30740700/django-templatedoesnotexist-
at-home-html
http://stackoverflow.com/questions/26176267/django-template-loader-cant-
find-template/30588425#30588425
and so on.
Django should explicitly warn in this case, telling users to move their
directories settings to `TEMPLATES`.
--
Ticket URL: <https://code.djangoproject.com/ticket/25079>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> Since the addition of the pluggable template backends, the
> `TEMPLATE_DIRS` setting has been deprecated in favour of the `TEMPLATES`
> list of dicts. If `TEMPLATES` is not defined, it will be constructed
> using the value of `TEMPLATE_DIRS`.
>
> However, `TEMPLATES` is created automatically by the default project
> template; and in this case Django does not use the value in
> `TEMPLATE_DIRS`. This means that users following pre-1.8 tutorials (for
> example, the very popular Tango with Django) will be instructed to add
> `TEMPLATE_DIRS` to a settings file that ignores that value, and then will
> be surprised that their templates are not found. This has hit quite a few
> users on StackOverflow, for example:
>
> http://stackoverflow.com/questions/31108314/templatedoesnotexist-error-
> in-django/31109213
> http://stackoverflow.com/questions/30844500/django-templatedoesnotexist-
> error-on-windows-machine
> http://stackoverflow.com/questions/30740700/django-templatedoesnotexist-
> at-home-html
> http://stackoverflow.com/questions/26176267/django-template-loader-cant-
> find-template/30588425#30588425
>
> and so on.
>
> Django should explicitly warn in this case, telling users to move their
> directories settings to `TEMPLATES`.
New description:
Since the addition of the pluggable template backends, the `TEMPLATE_DIRS`
setting has been deprecated in favour of the `TEMPLATES` list of dicts. If
`TEMPLATES` is not defined, it will be constructed using the value of
`TEMPLATE_DIRS`.
However, `TEMPLATES` is created automatically by the default project
template; and in this case Django does not use the value in
`TEMPLATE_DIRS`. This means that users following pre-1.8 tutorials (for
example, the very popular Tango with Django) will be instructed to add
`TEMPLATE_DIRS` to a settings file that ignores that value, and then will
be surprised that their templates are not found. This has hit quite a few
users on StackOverflow, for example:
http://stackoverflow.com/questions/31108314/templatedoesnotexist-error-in-
django/31109213
http://stackoverflow.com/questions/30844500/django-templatedoesnotexist-
error-on-windows-machine
http://stackoverflow.com/questions/30740700/django-templatedoesnotexist-
at-home-html
http://stackoverflow.com/questions/26176267/django-template-loader-cant-
find-template/30588425#30588425
and so on.
Django should explicitly warn in this case, telling users to move their
directories settings to `TEMPLATES`.
PR: https://github.com/django/django/pull/4959
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:1>
Comment (by timgraham):
Is there a reason not to add similar warnings for all deprecated
`TEMPLATE_` settings? I guess the main problem with this would be on
projects that deliberately define both settings for compatibility with
multiple versions of Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:2>
Comment (by danielr):
I hadn't considered the other template settings - `DIRS` is the one that
people need to modify in order to get their templates loading at all, so
is the biggest concern. If you think it's valuable though I can loop
through all the `TEMPLATE_*` settings and raise a warning if they are
present.
For the compatibility issue, that's really why it's a warning rather than
an ImproperlyConfigured exception; warnings are easily silenced or even
just ignored.
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:3>
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:4>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"24620d71f2116da31abe6c9391f7bc807ac23c0b" 24620d7]:
{{{
#!CommitTicketReference repository=""
revision="24620d71f2116da31abe6c9391f7bc807ac23c0b"
Fixed #25079 -- Added warning if both TEMPLATES and TEMPLATE_* settings
are defined.
Django ignores the value of the TEMPLATE_* settings if TEMPLATES is also
set, which is confusing for users following older tutorials. This change
adds a system check that warns if any of the TEMPLATE_* settings have
changed from their defaults but the TEMPLATES dict is also non-empty.
Removed the TEMPLATE_DIRS from the test settings file; this was marked
for removal in 1.10 but no tests fail if it is removed now.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"4cc0baa98e8a5bb8f2cf91539d141cbc30af6f61" 4cc0baa9]:
{{{
#!CommitTicketReference repository=""
revision="4cc0baa98e8a5bb8f2cf91539d141cbc30af6f61"
[1.8.x] Fixed #25079 -- Added warning if both TEMPLATES and TEMPLATE_*
settings are defined.
Django ignores the value of the TEMPLATE_* settings if TEMPLATES is also
set, which is confusing for users following older tutorials. This change
adds a system check that warns if any of the TEMPLATE_* settings have
changed from their defaults but the TEMPLATES dict is also non-empty.
Removed the TEMPLATE_DIRS from the test settings file; this was marked
for removal in 1.10 but no tests fail if it is removed now.
Backport of 24620d71f2116da31abe6c9391f7bc807ac23c0b from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"98760ab0b2f1ce03234a5e6a52decd9f23d3994a" 98760ab]:
{{{
#!CommitTicketReference repository=""
revision="98760ab0b2f1ce03234a5e6a52decd9f23d3994a"
Refs #25079 -- Removed obsolete system check for TEMPLATE_* settings.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25079#comment:8>