Fixed #18617 -- Highlighted that the app_directories template loader depends on the order of INSTALLED_APPS.

Thanks evildmp for the patch.
This commit is contained in:
Aymeric Augustin 2012-07-12 23:02:58 +02:00
parent e806f047f3
commit 8c670ee347
1 changed files with 15 additions and 5 deletions

View File

@ -649,14 +649,24 @@ class. Here are the template loaders that come with Django:
INSTALLED_APPS = ('myproject.polls', 'myproject.music') INSTALLED_APPS = ('myproject.polls', 'myproject.music')
...then ``get_template('foo.html')`` will look for templates in these ...then ``get_template('foo.html')`` will look for ``foo.html`` in these
directories, in this order: directories, in this order:
* ``/path/to/myproject/polls/templates/foo.html`` * ``/path/to/myproject/polls/templates/``
* ``/path/to/myproject/music/templates/foo.html`` * ``/path/to/myproject/music/templates/``
Note that the loader performs an optimization when it is first imported: It ... and will use the one it finds first.
caches a list of which :setting:`INSTALLED_APPS` packages have a
The order of :setting:`INSTALLED_APPS` is significant! For example, if you
want to customize the Django admin, you might choose to override the
standard ``admin/base_site.html`` template, from ``django.contrib.admin``,
with your own ``admin/base_site.html`` in ``myproject.polls``. You must
then make sure that your ``myproject.polls`` comes *before*
``django.contrib.admin`` in :setting:`INSTALLED_APPS`, otherwise
``django.contrib.admin``'s will be loaded first and yours will be ignored.
Note that the loader performs an optimization when it is first imported:
it caches a list of which :setting:`INSTALLED_APPS` packages have a
``templates`` subdirectory. ``templates`` subdirectory.
This loader is enabled by default. This loader is enabled by default.