我有一个db对象:
class form_info(db.Model):
salary = db.IntegerProperty(required = True)
curr_age = db.IntegerProperty(required = True)
retire_age = db.IntegerProperty(required = True)
goal = db.IntegerProperty(required = True)
此方法的发布方法如下:
def post(self):
self.form_info=form_info(salary=int(self.request.get("salary")),curr_age=int(self.request.get("age")),retire_age=int(self.request.get("age_retire")),goal=int(self.request.get("goal")))
self.form_info.put()
self.redirect("/")
有没有办法在发布后返回对象的键?谢谢
答案 0 :(得分:0)
在post方法中,您可以获取对象的键:
key = self.form_info.put()
如果你正在寻找实际从post方法返回键值的话,你应该看看这个Q& A:What REST PUT/POST/DELETE calls should return by a convention?
如果您正在寻找一种跨请求分享价值的方式(即将其提供给重定向的获取请求),您应该查看此问答:Passing data between pages in a redirect() function in Google App Engine