我知道这很简单,但我没能成功。 我将数据添加到数据库,但我单击按钮我的页面将转到另一个页面。因为我写了重定向行。但如果我不写,我的过程就没用了。我的代码是:
你知道吗主.py你知道吗
class AddWord(webapp2.RequestHandler):
def post(self):
word = Word()
word.name = self.request.get("content")
word.put()
query_params = {'you added': word.name }
self.redirect('/?' + urllib.urlencode(query_params))
application = webapp2.WSGIApplication([
('/', MainPage),
('/add', AddWord),
], debug=True)
我的索引.html你知道吗
<body>
<form action="/add?" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Send Word"></div>
</form>
当我把单词写到textarea并单击按钮时,我不想去任何地方,但我不能处理表单操作参数和其他参数。你能告诉我我必须做什么吗?谢谢。你知道吗
只需在def get()上对def post()进行相同的呈现,并应用相同的变量以用新消息重新创建页面。你知道吗
相关问题 更多 >
编程相关推荐