App Engine - AttributeError: 'function' object has no attribute 'id'
Question: I'm using App Engine, SDK 1.6.3 with Python 2.7.

I've created a model like this:

    
    
    class MyModel(db.Model):
        name = db.StringProperty()
        website = db.StringProperty()
    

I can iterate and see everything except the Key id's. For example, in the
interactive shell I can run this:

    
    
    from models import *
    list = MyModel.all()
    for p in list:
        print(p.name)
    

and it prints the name of every Entity. But when I run this:

    
    
    from models import *
    list = MyModel.all()
    for p in list:
        print(p.key.id)  [or p.key.name or p.key.app]
    

I get an AttributeError:

    
    
    Traceback (most recent call last):
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/admin/__init__.py", line 317, in post
        exec(compiled_code, globals())
      File "<string>", line 4, in <module>
    AttributeError: 'function' object has no attribute 'id'
    

Can anyone please help me??


Answer: key() and id() are instance methods. Try with parenthesis:

    
    
       for p in list:
            print(p.key().id())
    

See the
[documentation](http://code.google.com/appengine/docs/python/datastore/keyclass.html#Key).

