Dynamically specify TEMPLATE_DIRS

1
2
3
4
5
import os
dirname = os.path.dirname(globals()["__file__"])
TEMPLATE_DIRS = (
    os.path.join(dirname, 'application_directory/templates'),
)

More like this

  1. Dynamic Template Loader by jgeewax 5 years, 9 months ago
  2. manage.py with magic python path by bikeshedder 6 years, 10 months ago
  3. easy absolute path for settings.py by pgugged 5 years, 10 months ago
  4. Jinja2 Django integration by mathwizard 5 years, 7 months ago
  5. Ensure ugettext is available absolutely everywhere by ElfSternberg 4 years, 10 months ago

Comments

whiskybar (on February 28, 2007):

I used to use the exact same code but then I discovered you can achieve the same by

TEMPLATE_LOADERS = (
    "django.template.loaders.app_directories.load_template_source",
)
TEMPLATE_DIRS = ()

#

(Forgotten your password?)