tags:

views:

44

answers:

1

I am currently just add app to INSTALLED_APPS to be able to use templates from that app, but there is also TEMPLATE_DIRS setting. When have I to prefer TEMPLATE_DIRS over INSTALLED_APPS?

+3  A: 

You can use templates in TEMPLATE_DIRS to either override templates coming from apps (by giving them the same name) or for templates that are relevant for more than one app (base.html comes to mind).

This works because of the order in which template loaders are set in TEMPLATE_LOADERS (filesystem before app_directories).

It's a good idea to organize your templates in the following way to avoid name collisions:

<project>/
    <app1>/templates/<app1>/
        foo.html
        bar.html
    <app2>/templates/<app2>/
        foo.html
    templates/
        <app1>/
            foo.html
        base.html
        xyzzy.html
hop