mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
81cbf27a13
commit
cc3635d62f
|
@ -1,6 +1,7 @@
|
||||||
# Wrapper for loading templates from "template" directories in installed app packages.
|
# Wrapper for loading templates from "template" directories in installed app packages.
|
||||||
|
|
||||||
from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION
|
from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.template import TemplateDoesNotExist
|
from django.core.template import TemplateDoesNotExist
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -8,8 +9,17 @@ import os
|
||||||
app_template_dirs = []
|
app_template_dirs = []
|
||||||
for app in INSTALLED_APPS:
|
for app in INSTALLED_APPS:
|
||||||
i = app.rfind('.')
|
i = app.rfind('.')
|
||||||
|
if i == -1:
|
||||||
|
m, a = app, None
|
||||||
|
else:
|
||||||
m, a = app[:i], app[i+1:]
|
m, a = app[:i], app[i+1:]
|
||||||
|
try:
|
||||||
|
if a is None:
|
||||||
|
mod = __import__(m, '', '', [])
|
||||||
|
else:
|
||||||
mod = getattr(__import__(m, '', '', [a]), a)
|
mod = getattr(__import__(m, '', '', [a]), a)
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])
|
||||||
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
|
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
|
||||||
if os.path.isdir(template_dir):
|
if os.path.isdir(template_dir):
|
||||||
app_template_dirs.append(template_dir)
|
app_template_dirs.append(template_dir)
|
||||||
|
|
Loading…
Reference in New Issue