gae_mini_profiler {%profiler_includes%}给出了无效的块标记:'profiler_includes' [英] gae_mini_profiler {% profiler_includes %} gives Invalid block tag: 'profiler_includes'

查看:104
本文介绍了gae_mini_profiler {%profiler_includes%}给出了无效的块标记:'profiler_includes'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to install gae_mini_profiler in my django-nonrel app

我在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更改为真正的模板标签库来解决此问题.

I solved this by changing gae_mini_profiler/templatetags.py to be a true template tag library.

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

To do this create a package called templatetags, and then move(and rename) the templatetags.py module to profiler_tags.py.

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

Inside of profiler_tags.py make the following changes:

更改:

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

收件人:

from django.template import Library
register = Library()


更改:


Change:

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添加到您已安装的应用列表中.


In your settings file add gae_mini_profiler to your list of installed apps.

删除所有对

template.register_template_library('gae_mini_profiler.templatetags')


在您拥有{% profiler_includes %}的任何位置的模板中,您都需要添加一个加载块


In your templates whereever you had {% profiler_includes %} you then need to add a load block

 {% load profiler_tags %}

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

I think that is all of the changes, but need to go check my git log.

这篇关于gae_mini_profiler {%profiler_includes%}给出了无效的块标记:'profiler_includes'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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