gpt4 book ai didi

django - gae_mini_profiler {% profiler_includes %} 给出无效 block 标记 : 'profiler_includes'

转载 作者:太空宇宙 更新时间:2023-11-03 15:30:04 24 4
gpt4 key购买 nike

我正在尝试在我的 django-nonrel 应用程序中安装 gae_mini_profiler

我将 {% profiler_includes %} 标签放在了我的 base.html

的底部

结果是

Exception Type: TemplateSyntaxError
Exception Value: Invalid block tag: 'profiler_includes'

我放了

from gae_mini_profiler import profiler
application = profiler.ProfilerWSGIMiddleware(application)

djangoppengine/main/__init__.py 的底部

我遵循了 https://github.com/kamens/gae_mini_profiler#start 中的所有其他说明。

我做错了什么?

最佳答案

我通过将 gae_mini_profiler/templatetags.py 更改为真正的模板标签库来解决这个问题。

为此创建一个名为 templatetags 的包,然后将 templatetags.py 模块移动(并重命名)为 profiler_tags.py。

在 profiler_tags.py 内部进行以下更改:

改变:

from google.appengine.ext import webapp
register = webapp.template.create_template_register()

收件人:

from django.template import Library
register = Library()

改变:

path = os.path.join(os.path.dirname(__file__), "templates/includes.html")

收件人:

path = os.path.join(os.path.dirname(__file__), "../templates/includes.html")

在您的设置文件中,将 gae_mini_profiler 添加到您已安装的应用程序列表中。


删除对

的所有引用
template.register_template_library('gae_mini_profiler.templatetags')

在你的模板中,无论你有 {% profiler_includes %} 然后你需要添加一个加载 block

 {% load profiler_tags %}

我认为这就是所有更改,但需要检查我的 git 日志。

关于django - gae_mini_profiler {% profiler_includes %} 给出无效 block 标记 : 'profiler_includes' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8337262/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com