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. manage.py with magic python path by bikeshedder 5 years, 11 months ago
  2. Mobilize your Django site by stevena0 4 years, 1 month ago
  3. Jinja2 Django integration by mathwizard 4 years, 8 months ago
  4. 3rd Party App Directories by thalin 4 years, 10 months ago
  5. Ensure ugettext is available absolutely everywhere by ElfSternberg 3 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?)