0

I know this is simple but I couldn't succeed. I add data to database but I click the button my page is going to another page. Because I write redirect line. But if I don't write my process doesn't work. My codes are these:

main.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)

my index.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>

When I write my word to textarea and click to button I don't want to go anywhere, but I couldn't handle form action parameter and the others. Please can you tell me what I must do? Thanks.

4

1 回答 1

1

只需在你的 def get() 上进行相同的渲染到你的 def post() 中,并应用相同的变量来重新创建包含新消息的页面。

于 2013-07-30T19:55:22.907 回答