我在我的应用程序中创建了一个实体“FlipKart”,并使用了一个运行查询的处理程序,以便我可以在我的 HTML 表单中显示给定的条目。我有用于组织我的 html 文件的 Jinja2 模板。
这是实体的代码:
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>
但是,当我运行此应用程序时,我在浏览器中的表单后收到以下文本:
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
似乎是什么问题?