On 3/10/06, pbx <[EMAIL PROTECTED]> wrote:
>
> > So I just want to say maybe I'm not testing for this before, but I
> > only want to tell you some clues, and hope these clues can help you,
> > why not try it yourself and just complain to me?
>
> Sorry -- I should have clarified in the first post that this is about
> default behavior in the absence of a TEMPLATE_DIRS setting.
>
> The documentation here:
>
>
> http://www.djangoproject.com/documentation/templates_python/#loader-types
>
> explains: "For each app in INSTALLED_APPS, the loader looks for a
> templates subdirectory. If the directory exists, Django looks for
> templates in there." I like this system a lot, and don't use
> TEMPLATE_DIRS at all in most of my apps/projects.
>
you are right, if you use the way as you described. I checked the
template/load.py code, and the django will process template loading in
order by settings.TEMPLATE_LOADERS 。and you can see that :
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
so first dealing with filesystem.load_template_source then dealing
with app_directories.load_template_source , and in
template/loaders/app_directories.py,
app_template_dirs = []
for app in settings.INSTALLED_APPS:
i = app.rfind('.')
if i == -1:
m, a = app, None
else:
m, a = app[:i], app[i+1:]
try:
if a is None:
mod = __import__(m, '', '', [])
else:
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')
if os.path.isdir(template_dir):
app_template_dirs.append(template_dir)
It indeed search the template according to the order of INSTALLED_APPS.
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit
--~--~---------~--~----~------------~-------~--~----~
これは、お客様が次の Google グループに申し込まれたことを確認するメッセー
ジです。 Google Groups "Django developers" group.
To post to this group, send email to [email protected]
このグループから退会するには、次へメールをお送りください。 [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---