【问题标题】:Webapp2 custom tagsWebapp2 自定义标签
【发布时间】:2012-05-24 00:23:38
【问题描述】:

我正在从 webapp1 迁移到 webapp2 以及从 python 2.5 迁移到 python2.7 我有一些我使用的自定义标签

webapp.template.register_template_library('common.templatetags')

并注册于:

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

和相应的装饰器和其他一切都很好

现在我需要使用没有 template.register 的 webapp2.....

我试过这样做:http://www.john-smith.me/Tag/webapp2 但它没有工作

谢谢

【问题讨论】:

  • 通过使用 django add_to_builtins() 而不是使用不可调试的 {%load%} 标签修复了,这太浪费时间了:D
  • 你知道你可以回答你自己的问题吗?
  • 是的,但仅在 6 小时后,现在我需要等待 5 小时才能接受我自己的答案:D

标签: google-app-engine webapp2


【解决方案1】:

使用 add_to_builtins() 解决

from django.template.loader import add_to_builtins

add_to_builtins('myapp.templatetags.mytagslib')

【讨论】:

猜你喜欢
  • 2012-07-13
  • 2021-12-28
  • 2011-10-15
  • 2012-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多