这是我得到的错误:
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',
)),
]
当我从 Internet 下载该项目时,所有这些代码都在那里。我正在尝试设置 OSQA使用 these instructions .我正在运行 MS SQL Server 并安装了 Python 2.6。关于如何修复此错误的任何帮助 (当我尝试运行 manage.py
runserver 并点击设置我的东西的 http 链接时发现。错误在命令行中弹出)。我是 Django 和 Python 的新手,所以我真的不知道如何诊断正在发生的事情。
最佳答案
如果您查看 template loader types 上的文档(向下滚动到缓存模板加载器部分),看起来当你配置缓存加载器时你仍然需要传递它 Loader
类 - 所以你想改变你的配置看起来像这样:
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
类(您需要阅读文档在那个应用程序上弄清楚 - 并非所有第三方模板加载器都与缓存加载器一起工作)。
关于python - 配置 django 设置以使用 1.4.1。加载模板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11904609/