我在應用程序中創建了一個實體「FlipKart」,並使用了一個處理程序,我已經運行了一個查詢,以便可以在我的HTML表單中顯示給定條目。我有用於組織我的html文件的Jinja2模板。未顯示Google App Engine數據庫
下面是實體代碼:
class FlipKart(db.Model):
name = db.StringProperty()
quantity = db.IntegerProperty()
total = db.IntegerProperty()
這裏就是我處理和運行我的查詢處理程序:
class WebeHandler(Handler):
def get(self):
self.render("we.html")
def post(self):
b_name = self.request.get("bkname")
b_quantity = self.request.get("qnty")
b_total = self.request.get("tot")
if(b_name and b_quantity and b_total):
a = FlipKart(BookName = b_name, Quantity = b_quantity, GrandTotal = b_total)
a.put()
self.final()
def final(self):
flips = db.GqlQuery("SELECT * FROM FlipKart")
self.render("we.html", flips = flips)
這裏是我的html文件:
<html>
<head>
<title>Web Engineering</title>
<style type = "text/css">
</style>
</head>
<body>
<form method = "post">
Book Name<input type = "text" name = "bkname">
<br>
Quantity<input type = "text" name = "qnty">
<br>
Total Prize<input type = "number" name = "tot">
<br>
<input type = "submit">
<br><br><br>
<hr>
{%
for flip in flips
%}
<div>You have ordered a {{flip.name}}</div>
{%endfor%}
</form>
</body>
然而,whe n我運行這個應用程序,在瀏覽器中獲得以下文本:
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
You have ordered a None
什麼似乎是問題?