这是我得到的错误:
ImproperlyConfigured: Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"
这是我的加载器模板代码:
if DEBUG:
TEMPLATE_LOADERS = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
else:
TEMPLATE_LOADERS = [
('django.template.loaders.cached.Loader',(
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'forum.modules.template_loader.module_templates_loader',
'forum.skins.load_template_source',
)),
]
当我从互联网上下载项目时,所有这些代码都在那里。我正在尝试使用OSQA设置these instructions。我正在运行 MS SQL Server 并安装了 Python 2.6 。有关如何修复此错误的任何帮助(当我尝试运行manage.py
runserver并找到设置我的东西的http链接时找到。错误会在命令行中弹出)。我是 Django 和 Python 的新手,所以我真的不知道如何诊断正在发生的事情。
答案 0 :(得分:26)
如果你查看template loader types上的文档(向下滚动到缓存的模板加载器部分),看起来当你配置缓存的加载器时,你仍然需要传递它Loader
类 - 所以你和#39; d想要将配置更改为:
if DEBUG:
TEMPLATE_LOADERS = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]
else:
TEMPLATE_LOADERS = [
('django.template.loaders.cached.Loader',(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'forum.modules.template_loader.module_templates_loader',
'forum.skins.load_template_source',
)),
]
我不确定forum
应用程序的加载器是什么,但您可能也想要Loader
个类(您需要阅读有关该文档的文档)应用程序来解决这个问题 - 并非所有第三方模板加载器都使用缓存的加载程序。)
答案 1 :(得分:4)
P.S。我解决了我的问题并感谢How to fix the Django error displayed when loading Twissandra for the first time?