title: Retrieving key/ID values from app engine datastore?
body: <p>I've got a page on my Python app which has a drop-down box of locations associated with the current user, with the names of the locations as the visible values of the drop-down box. What I want to do is allow the user to select one of these locations to associate with their current location. When a user adds a new Location it is created as a child entity of that user, so I populate the drop-down box like this:</p>
  
  <pre><code>locinfo = db.GqlQuery("SELECT * FROM Location WHERE ANCESTOR IS :1", userinfo)
  </code></pre>
  
  <p>...and this is how I intend to display the drop-down box on the site (the i.key value is just a placeholder, I'll explain).</p>
  
  <pre><code>&lt;select name="lockey"&gt;
      {% for i in locinfo %}
          &lt;option value="{{i.key}}"&gt;{{i.locname}}&lt;/option&gt;
      {% endfor %}
  &lt;/select&gt;
  </code></pre>
  
  <p>So what I want to do is add a reference to one particular Location entity in a User record. In a normal relational database I would get the primary key of each location, print them out as the value of each option, and store them in the User record as a reference to the user's current location. However I've looked around and haven't found anything about retrieving the key, and the more I look around the more I get the impression I'm going about it the wrong way.</p>
  
  <p>Any suggestions?</p>