Google App Engine不显示任何内容

时间:2014-03-02 03:45:53

标签: python google-app-engine google-cloud-datastore

我正在尝试从用户获取数据并将其存储在数据库中,但即使我的表单也没有显示在chrome上。我是谷歌应用引擎的新手,请帮忙。以下是我的完整代码

import webapp2
from google.appengine.ext import db

class Dealer(db.Model):
   dealer_name = db.StringProperty(required = True)
   dealer_phone = db.StringProperty(required = True)

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write("""
        <form action="store_dealer" method="post">
            <input type="text" name="dealer_name">
            <input type="text" name="dealer_phone">
            <input type="submit"/>
        </form>
    """)

class StoreDealer(webapp2.RequestHandler):
    def post(self):
        dealer_name=self.request.get('dealer_name')
        dealer_phone=self.request.get('dealer_phone')
        if dealer_name && dealer_phone:
            dealer = Dealer(dealer_name = dealer_name, dealer_phone =     dealer_phone)
            dealer.put()
            self.redirect('/')

app = webapp2.WSGIApplication([
    ('/', MainHandler),
    ('/store_dealer',StoreDealer)
], debug=True)

1 个答案:

答案 0 :(得分:2)

Python中等效的&&and

所以你的代码应该是这样的。

class StoreDealer(webapp2.RequestHandler):
    def post(self):
        ..........
        if dealer_name and dealer_phone:
            ...........

要查看Google App Engine上的错误,请检查其日志控制台。