def load_template_source(self, template_name, template_dirs=None):
"""
Returns a tuple containing the source and origin for the given template
name.
Dispatch this to the underlying loaders.
"""
warnings.warn(
'The load_template_sources() method is deprecated. Use '
'get_template() or get_contents() instead.',
RemovedInDjango20Warning,
)
site = Site.objects.get_current()
label = settings.SITELABELS.label_from_site(site)
# put the prefixed template in front of the possible templates
names = [os.path.join(label, template_name), template_name]
for name in names: # always try to load the label-specific version first, independent from the loader
for loader in self.loaders:
try:
return loader.load_template_source(name, template_dirs=template_dirs)
except TemplateDoesNotExist:
pass
raise TemplateDoesNotExist("Tried %s" % ', '.join(names))
评论列表
文章目录