我已经通过关于app引擎数据存储的一些教程成功创建了示例实体“Shout”。但是当我试图创建Register表时(按照我创建的“Shout”所做的相同步骤),但它没有创建。
实际上在我的应用程序中我有注册页面,用户的注册数据应该存储在“注册”表中,稍后用于登录我检索uname和pwd以匹配用户从登录页面输入的数据。请帮我。我怎么能这样做。
这就是我想要的......
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
class Register(db.Model):
username=db.StringProperty(required="true")
email=db.StringProperty(required="true")
password=db.StringProperty(required="true")
cpassword=db.StringProperty(required="true")
class Shout(db.Model):
message=db.StringProperty(required="true")
when = db.DateTimeProperty(auto_now_add="true")
who = db.StringProperty()
class MainPage(webapp.RequestHandler):
def get(self):
shouts= db.GqlQuery('select * from Register order by when desc')
values={'shouts':shouts}
self.response.out.write(template.render('ui.html',values))
def post(self):
shoutt= Register(username=self.request.get('txt1'),email=self.request.get('txt2'),password=self.request.get('txt3'),cpassword=self.request.get('txt4'))
shoutt.put()
self.redirect('/')
class SecondPage(webapp.RequestHandler):
def post(self):
sec= db.GqlQuery('select * from Shout order by when desc')
values={'sec':sec}
self.response.out.write(template.render('login.html',values))
application = webapp.WSGIApplication([('/', MainPage),('/second', SecondPage)], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()