如何在google-app-engine中使用inbulit django templatetags [英] How to use inbulit django templatetags in google-app-engine

查看:100
本文介绍了如何在google-app-engine中使用inbulit django templatetags的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的谷歌应用程序中使用Django建立模板标记,如标记和
的人性化,但它不起作用。
我在INSTALLED_APPS中添加了标记和人性化。还是行不通。
如何使用?

解决方案

这里是如何做到人性化的,别人应该是类似的。在调用模板的控制器的末尾有一个如下功能:

  def main():
run_wsgi_app(application)

在def main()之后添加以下两行:

  from google.appengine.ext.webapp import template 
template.register_template_library(
'django.contrib.humanize.templatetags .humanize')

无需在模板中添加{%load humanize%}。



感谢这个帖子 http://blog.yjl.im/2011/02/few-things-on-google-app-engine-i.html 暗示了我的解决方案。


I am trying to use Django in built templatetags like markup and humanize in my google app , but its not working. I added markup and humanize in the INSTALLED_APPS. Still not working. How to use that?

解决方案

Here is how to do it for humanize, others should be similar. At the end of the controller that invokes your template there is a function that looks like:

def main():
    run_wsgi_app(application)

Add the following two lines just after def main():

from google.appengine.ext.webapp import template
template.register_template_library(
             'django.contrib.humanize.templatetags.humanize')

No need to add {% load humanize %} in your template.

Thanks to this posting http://blog.yjl.im/2011/02/few-things-on-google-app-engine-i.html that hinted the solution for me.

这篇关于如何在google-app-engine中使用inbulit django templatetags的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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