脚本在 data.py 中,模板文件是 search.mako。搜索表单在 MainPage 方法中(不包含在下面的代码中)。我输入了搜索词,但没有任何反应。你能帮助理解我做错了什么吗?谢谢你。
class Pet(db.Model):
name = db.StringProperty()
class Search(webapp.RequestHandler):
def post(self):
query = Pet.all()
results = self.request.get('searchquery')
q = query.filter('name =', 'results')
template_values = {'q': q,}
path = os.path.join(os.path.dirname(__file__), 'search.mako')
templ = Template(filename=path)
self.response.out.write(templ.render(**template_values))
这就是 search.mako
<html>
<body>
% for cat in q:
<p>${cat.name}</p>
% endfor
</html>
</body>