配置django设置以使用1.4.1。加载模板错误 [英] Configuring django settings to work with 1.4.1. Loading template error

查看:168
本文介绍了配置django设置以使用1.4.1。加载模板错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我得到的错误:

ImproperlyConfigured: Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"

这是我的加载器模板代码: / p>

Here is my loader template code:

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 Windows + Vista + + + SQLServer>这些说明。我正在运行 MS SQL Server ,并安装了 Python 2.6 。有关如何解决此错误的任何帮助(当我尝试运行 manage.py runserver时找到并点击我的东西设置的http链接,错误弹出在命令行中)。我刚刚接触到 Django Python ,所以我不太了解如何诊断发生了什么。

All of this code was there when I downloaded the project from the internet. I'm trying to setup OSQA using these instructions. I'm running MS SQL Server and have Python 2.6 installed. Any help on how to fix this error (found when I try to run manage.py runserver and hit the http link where my stuff is setup. the error pops up in the command line). I'm new to Django and Python so I don't really know to how to diagnose what is happening.

推荐答案

如果您查看模板加载器类型(向下滚动到缓存的模板加载器部分),它看起来像是配置缓存加载器时仍然需要传递它 Loader 类 - 所以你想改变你的配置如下所示:

If you look at the documentation on template loader types (scroll down to the cached template loader section), it looks like when you configure the cached loader you still need to pass it Loader classes - so you'd want to change your config to look like this:

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',
            )),
    ]

我不知道装载程序是什么用于论坛应用程序,但您可能还需要code> Loader 类(您需要阅读该应用程序的文档,以便了解这一点 - 并非所有第三方模板加载程序与缓存的加载程序一起使用)。

I'm not sure what the loaders are for the forum app, but you probably also want Loader classes there as well (you'll need to read the documentation on that app to figure that out - not all third party template loaders work with the cached loader).

这篇关于配置django设置以使用1.4.1。加载模板错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆