0

I have a db object :

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)

The posting method for this is as follows:

    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("/")

Is there a way to return the key of the object after posting? Thank you

1 Answers1

0

In the post method you can get the key of the object:

key = self.form_info.put()

If you're looking for actually returning the key value from the post method you should look at this Q&A : What REST PUT/POST/DELETE calls should return by a convention?

If you're looking for a way to share the value across requests (i.e. making it available to the redirected get request) you should look at this Q&A : Passing data between pages in a redirect() function in Google App Engine

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97