How to use inbulit django templatetags in google-app-engine

*爱你&永不变心* 提交于 2019-12-07 06:22:35

问题


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?


回答1:


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.




回答2:


It is possible to do this, but you'll need to provide more information before your particular situation can be addressed. It sounds like there might be an exception that is being thrown--is this the case? If there is one, what is being printed out to the console (or the log)?

I'm using app-engine-patch and have been able to use both django.contrib.humanize and django.contrib.markup, so you might see if this works for you.



来源:https://stackoverflow.com/questions/901121/how-to-use-inbulit-django-templatetags-in-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!