title: Google app engine ReferenceProperty view won't post/save
body: <p>Here are my models and views. I'm new to App Engine and I am trying to create a new language set with a relationship to profiletitle. I've read through a ton of posts/docs and can't find a good example of functional view code.</p>
  
  <p>models.py</p>
  
  <pre><code>class AddProfile(db.Model):
      profiletitle = db.StringProperty(required=True)
  
  
  class AddLang(db.Model):
      profile = db.ReferenceProperty(AddProfile, required=True)
      language = db.StringListProperty()
      date = db.DateTimeProperty(auto_now_add=True)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>class CreateLang(BaseHandler):
  
      def post(self):
          n = AddLang(
          profile = self.request.get('profile'),
          language = self.request.get('language').split(', '))
          n.put()
          return webapp2.redirect('/')
  
      def get(self):
          self.render_template('create.html', {})
  </code></pre>
  
  <p>updated view.py - this now stores data in the datastore</p>
  
  <pre><code>class CreateLang(BaseHandler):
  
      def post(self):
          n = AddLang(
          profile = AddProfile.all().filter('profiletitle', self.request.get('profile')).get(),
          language = self.request.get('language').split(', '))
          n.put()
          return webapp2.redirect('/')
  
      def get(self):
          self.render_template('create.html', {})
  </code></pre>
  
  <p>create.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;body&gt;
  &lt;form action="" method="post"&gt;
    &lt;div class="field-wrapper"&gt;
  
      &lt;div class="field-label"&gt;
        &lt;label for="id_profile"&gt;Profile&lt;/label&gt;:
      &lt;/div&gt;
  
      &lt;div class="field-field"&gt;
        &lt;input type="text" name="profile" id="id_profile" /&gt;
  
      &lt;/div&gt;
  
   &lt;/div&gt;
  
    &lt;div class="field-wrapper"&gt;
  
      &lt;div class="field-label"&gt;
        &lt;label for="id_language"&gt;Language&lt;/label&gt;:
      &lt;/div&gt;
  
      &lt;div class="field-field"&gt;
        &lt;input type="text" name="language" id="id_language" /&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
    &lt;br&gt;
    &lt;input type="submit" value=submit /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I attempt to post/save the data I receive the following error. I believe this is caused because I need to use the get to call the specific id of the profiletitle selected in my template.</p>
  
  <p>Note: I am not using a form py, I have a simple html template. Let me know if you have any questions or need to see the template. Thanks for reading/helping. </p>
  
  <pre><code>     ![datastore snip]:(http://imm.io/1hTVN)
  
   Error Message
       if value is not None and not value.has_key():
  
   AttributeError: 'unicode' object has no attribute 'has_key'
  </code></pre>