loaders.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:django-label-loaders 作者: maykinmedia 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号