我试图在 Google App Engine Web 应用程序中包含以下标签:
http://www.djangosnippets.org/snippets/1357/ http://www.djangosnippets.org/snippets/1357/
该文件是否有任何配置可以使其与 Google App Engine 一起使用?
因为我遵循了 Django 模板教程:http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
并具有以下结构:
templatetags/
__init__.py
range_template.py
在模板文件中,我有 {%load range_template%}
但我收到错误:
TemplateSyntaxError:“range_template”不是有效的标签库:无法从 django.templatetags.range_template 加载模板库,没有名为 range_template 的模块
另一个可能导致此不起作用的问题是 INSTALL_APPS settings.py 文件。不知道如何配置它。
我的应用程序的根目录中有一个 settings.py 文件,其中包含以下内容:
INSTALLED_APPS = ('模板标签')
任何建议将不胜感激。
尝试执行以下操作:
$ python ./manage.py startapp foo
将 foo 添加到已安装的应用程序中:
INSTALLED_APPS += ('foo',)
并将 templatetags 目录移动到 foo 应用程序中。就像是:
./djangoproject
__init__.py
settings.py
urls.py
etc..
foo/
__init__.py
templatetags/
__init__.py
range_template.py
Django 约定是模板标签代码驻留在应用程序中名为 templatetags 的目录中(see docs http://docs.djangoproject.com/en/dev/howto/custom-template-tags/)。我想 GAE 也是如此。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)