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. 3rd Party App Directories by thalin 3 years, 10 months ago
  2. Simple profile middleware by limodou 5 years, 2 months ago
  3. Dynamic Template Loader by jgeewax 3 years, 10 months ago
  4. Dynamic Backends by LorenDavie 3 years, 7 months ago
  5. Mobilize your Django site by stevena0 3 years, 1 month 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?)