Code

Ticket #19548: namespace_search.diff

File namespace_search.diff, 1.1 KB (added by mcanix@…, 16 months ago)

Diff for module path template lookup

Line 
1diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py
2index 887f8a0..e889a27 100644
3--- a/django/template/loaders/app_directories.py
4+++ b/django/template/loaders/app_directories.py
5@@ -23,11 +23,14 @@ for app in settings.INSTALLED_APPS:
6         mod = import_module(app)
7     except ImportError as e:
8         raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
9-    template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
10-    if os.path.isdir(template_dir):
11-        if not six.PY3:
12-            template_dir = template_dir.decode(fs_encoding)
13-        app_template_dirs.append(template_dir)
14+
15+    # Search ALL the directories in the app module path
16+    for path in mod.__path__:
17+        template_dir = os.path.join(path, 'templates')
18+        if os.path.isdir(template_dir):
19+            if not six.PY3:
20+                template_dir = template_dir.decode(fs_encoding)
21+            app_template_dirs.append(template_dir)
22 
23 # It won't change, so convert it to a tuple to save memory.
24 app_template_dirs = tuple(app_template_dirs)