【发布时间】:2014-08-06 09:56:02
【问题描述】:
我正在使用带有 Python 和 jinja2 模板的 appengine。
我在处理过程中遇到了一个问题:我用这段代码渲染了一个游戏列表
self.templateValues = {}
self.templateValues['title'] = 'GalaStore'
self.templateValues['values'] = kw
gamesQuery = Game.all()
values = {'games' : gamesQuery.run()}
self.templateValues['gl'] = values
template = JINJA_ENVIRONMENT.get_template(template)
self.response.out.write(template.render(self.templateValues))
然后我的 html 中有一些按钮过滤器,每个人都调用不同的 js 函数。问题是:一旦我点击过滤器“按alpha排序”并通过js(通过ajax)调用python函数“sortByAlpha”,如何在运行时更新模板变量而不再次调用template.render()函数?这将导致整个页面的重新加载,我想避免它。 非常感谢!
【问题讨论】:
标签: python google-app-engine templates variables jinja2