title: Python what does it mean "AttributeError: 'unicode' object has no attribute 'has_key' "
body: <p>I would like to ask what does it mean "AttributeError: 'unicode' object has no attribute 'has_key'"
  Here is the full stack trace:</p>
  
  <pre><code>Traceback (most recent call last):
    File     "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\webapp\__init__.py", line 509, in __call__
      handler.post(*groups)
    File "D:\Projects\workspace\foo\src\homepage.py", line 71, in post
      country=postedcountry
    File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\db\__init__.py", line 656, in __init__
      prop.__set__(self, value)
    File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\db\__init__.py", line 2712, in __set__
      value = self.validate(value)
    File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\db\__init__.py", line 2742, in validate
      if value is not None and not value.has_key():
  AttributeError: 'unicode' object has no attribute 'has_key'
  </code></pre>
  
  <p>Let me describe a little bit more about the situation:</p>
  
  <ul>
  <li><p>First I created the models.py that has the db.Model for CMSRequest which has an attribute country that reference to the CMSCountry class</p>
  
  <pre><code>class CMSRequest(db.Model):
    country = db.ReferenceProperty(CMSCountry, required=True)
  
  class CMSCountry(db.Model):
    name = db.StringProperty(required=True)
  </code></pre></li>
  <li><p>Then, I created a bulkloader class to import the data into the CMSCountry</p></li>
  <li><p>In the form, user can select the country from the drop down list box, the results are posted back and save to the CMSRequest object</p>
  
  <pre><code>def post(self):
    postedcountry = self.request.get('country')
    cmsRequest = models.CMSRequest(postedcountry)
  </code></pre></li>
  </ul>
  
  <p>Maybe I have found the solution to my question, it is because I have not converted the posted key of CMSCountry back to save to the CMSRequest.</p>
  
  <p>Thank you everyone! </p>