Mirage
Mirage

Reputation: 31568

How can I include the template_dir in django settings

In the django settings.py its asking for TEMPLATE_DIR.

Rather than hard coding the path there I want to have templates folder inside the each app, e.g.

coresite/templates
blog/templates
gallery/templates

How can make that generic? Or do I have to add the templates for each app I have in my base site?

Upvotes: 0

Views: 312

Answers (1)

Rohan
Rohan

Reputation: 53386

You can add django.template.loaders.app_directories.Loader to TEMPLATE_LOADERS in the settings.py file, which will try to load templates from each installed app's templates sub directory.

e.g.

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

More info: Template loader types

Upvotes: 4

Related Questions