I have an entity called Author. Below is the ndb class:
class Author(ndb.Model):
name = ndb.StringProperty()
website = ndb.StringProperty()
bio = ndb.StringProperty()
profile_image_url = ndb.StringProperty()
slug = ndb.ComputedProperty(lambda self: make_slug(self.name))
I am creating an author object like this
author = Author(id=pk, **author_dict)
author.put()
There is no error when creating an author object for the first time.
I am retrieving an author object like this
author = Author.get_by_id(pk)
when I try to access the author bio field I get an AttributeError
author.bio = bio_text
The error comes when accessing a field on a existing author object. Error does not come on all fields.
The console is showing all the columns. The bio column is present in the datastore console for author entity.
I deleted all the author entities and made new entries. Still I am getting AttributeError.
I have several entities in datastore but I am getting this error only for Author entity.
Error statement:
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py",
line 2990, in _set_attributes
prop = getattr(cls, name) # Raises AttributeError for unknown properties.
AttributeError: type object 'Author' has no attribute 'bio'
CLOSED:
I had a class called Author in another module. This class was being used by NDB somehow to create the author entity and was causing this behaviour.
bioattribute. So it seems that you are overwritingauthorsomewhere in your code. - snakecharmerbtype(author)andauthor.__name__just before the line that's failing, to see whatauthoractually is. - snakecharmerb