Ticket #583: settings.patch

File settings.patch, 1.0 KB (added by sune.kirkeby@…, 9 years ago)
  • django/conf/settings.py

     
    4444            setting_value = (setting_value,) # In case the user forgot the comma.
    4545        setattr(me, setting, setting_value)
    4646
     47# Add templates/ directories from INSTALLED_APPS to TEMPLATE_DIRS,
     48# [ Note -- There is a good reason i jump through these hoops, if the
     49# original TEMPLATE_DIRS setting was a list-instance, we should keep it
     50# that way. ]
     51tds_type = type(me.TEMPLATE_DIRS)
     52tds = list(me.TEMPLATE_DIRS)
     53for app in me.INSTALLED_APPS:
     54    m, a = app.rsplit('.', 1)
     55    m = getattr(__import__(m, globals(), locals(), [a]), a)
     56    app_root = os.path.dirname(m.__file__)
     57    td = os.path.join(app_root, 'templates')
     58    if os.path.isdir(td):
     59        tds.append(td)
     60me.TEMPLATE_DIRS = tds_type(tds)
     61
    4762# save DJANGO_SETTINGS_MODULE in case anyone in the future cares
    4863me.SETTINGS_MODULE = os.environ.get(ENVIRONMENT_VARIABLE, '')
    4964
Back to Top