我正在尝试在我的django-nonrel应用程序中安装gae_mini_profiler
我在base.html的底部放置了{% profiler_includes %}标签
它会导致一个
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上的所有其他说明
我做错了什么?
发布于 2012-04-05 02:19:18
我通过将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 %},就需要添加一个加载块
{% load profiler_tags %}我认为这是所有的更改,但需要去检查我的git日志。
发布于 2011-12-01 17:17:46
您是否正在为GAE使用新的Python 2.7运行时?如果是这样的话,django模板设置略有不同,gae_mini_profiler还没有升级(欢迎任何人提交这个补丁,还没有得到它)。
这应该很容易解决,因为您唯一需要做的就是找到一种方法来在页面中的任何位置呈现由gae_mini_profiler.templatetags.profiler_includes()返回的HTML字符串。如果内置的模板标记不能按原样工作,有许多方法可以实现这一点。如果绝对必要的话,你可以简单地在你的基本请求处理程序中调用这个函数,并将得到的html传递到你的基本模板中(尽管这是一个不可否认的错误)。
我们希望很快就能让Python2.7与gae_mini_profiler一起工作。如果你不是在Python2.7上,我不确定是什么问题,因为我希望当前的代码可以工作……
https://stackoverflow.com/questions/8337262
复制相似问题