Flask-Themes不算Bug的Bug:模板找不到

本文介绍了解决Flask-Themes版本0.1.3中模板文件无法被正确加载的问题,提供了两种修改方法,并指出该插件已停止官方维护。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Flask-Themes版本0.1.3, 主要提示无法找到模板文件,经过跟踪发现有个不知道算不算BUG的地方(330行):

pythondef list_templates(self):
    res = []
    ctx = _request_ctx_stack.top
    if USING_BLUEPRINTS and not self.as_blueprint:
        fmt = '_themes/%s/%s'
    else:
        fmt = '%s/%s'
    for ident, theme in ctx.app.theme_manager.themes.iteritems():
        res.extend((fmt % (ident, t)).encode("utf8") for t in heme.jinja_loader.list_templates())
    return res

要把:

pythonif USING_BLUEPRINTS and not self.as_blueprint:

改为:

pythonif USING_BLUEPRINTS and self.as_blueprint:

模板文件就可以找到了。

上面是第一种方法。

第二种方法:

找到419行:

python    templatepath = '_themes/%s/%s' % (theme, templatename)

去掉这行,添加下面4行:

python    if USING_BLUEPRINTS:
        templatepath = '%s/%s' % (theme, templatename)
    else:
        templatepath = '_themes/%s/%s' % (theme, templatename)

不过这个插件原作者不更新了,有其他的爱好者在更新。

原文:http://flask123.sinaapp.com/article/56/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值