Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #663 -- app_directories template loader no longer assumes a dot…

… in the app name. Thanks, Sune

git-svn-id: http://code.djangoproject.com/svn/django/trunk@985 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cc3635d62fa414ea7e4a263f0ae8e141b62fa8b6 1 parent 81cbf27
Adrian Holovaty authored
14  django/core/template/loaders/app_directories.py
... ...
@@ -1,6 +1,7 @@
1 1
 # Wrapper for loading templates from "template" directories in installed app packages.
2 2
 
3 3
 from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION
  4
+from django.core.exceptions import ImproperlyConfigured
4 5
 from django.core.template import TemplateDoesNotExist
5 6
 import os
6 7
 
@@ -8,8 +9,17 @@
8 9
 app_template_dirs = []
9 10
 for app in INSTALLED_APPS:
10 11
     i = app.rfind('.')
11  
-    m, a = app[:i], app[i+1:]
12  
-    mod = getattr(__import__(m, '', '', [a]), a)
  12
+    if i == -1:
  13
+        m, a = app, None
  14
+    else:
  15
+        m, a = app[:i], app[i+1:]
  16
+    try:
  17
+        if a is None:
  18
+            mod = __import__(m, '', '', [])
  19
+        else:
  20
+            mod = getattr(__import__(m, '', '', [a]), a)
  21
+    except ImportError, e:
  22
+        raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])
13 23
     template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
14 24
     if os.path.isdir(template_dir):
15 25
         app_template_dirs.append(template_dir)

0 notes on commit cc3635d

Please sign in to comment.
Something went wrong with that request. Please try again.