Note that there are some explanatory texts on larger screens.

plurals
  1. POgoogle app engine (python) confusing class 'object has no attribute' error
    primarykey
    data
    text
    <p>I have a 2 classes.<br> One looks like this:</p> <pre><code>class Feed(db.Model): bid = db.StringProperty() title = db.StringProperty() url = db.StringProperty() datecreated = db.DateProperty(auto_now_add=True) voice = db.StringProperty() lastchecked = db.DateProperty(auto_now=True) language = db.StringProperty() active = db.BooleanProperty() posts = db.ListProperty(db.Key) </code></pre> <p>The other looks like this:</p> <pre><code>class Post(db.Model): title = db.StringProperty() postdate = db.DateTimeProperty() author = db.StringProperty() body = db.TextProperty() link = db.LinkProperty() hasmp3 = db.BooleanProperty() mp3location = db.StringProperty() processed = db.BooleanProperty() voice = db.StringProperty() length = db.FloatProperty() inprocess = db.BooleanProperty() haspict = db.BooleanProperty() pictures = db.ListProperty(db.Key) </code></pre> <p>I am trying to update a Feed by appending a Post like this:</p> <pre><code>blogid = cgi.escape(self.request.get('bid')) postid = cgi.escape(self.request.get('pid')) blog = Feed.get_by_key_name(blogid) post = Post.get_by_key_name(postid) if post.key() not in blog.posts: blog.posts.append(post.key()) blog.put() </code></pre> <p>When I attempt to 'put' the blog with the post information, python doesn't like it and tells me</p> <blockquote> <pre><code>AttributeError: 'Feed' object has no attribute 'posts' </code></pre> </blockquote> <p>The reason I am so confused is because I have nearly the exact logic in adding a 'Feed' to a 'UserClass' where the 'UserClass' has 'Feeds' designated as a ListProperty in the same way that a 'Feed' has a 'Post' designated as a ListProperty.</p> <p>This is an example of what I mean:</p> <pre><code>class UserClass(db.Model): synccode = db.StringProperty() firstname = db.StringProperty() lastname = db.StringProperty() address = db.StringProperty() address2 = db.StringProperty() city = db.StringProperty() state = db.StringProperty() zipcode = db.StringProperty() emailaddress = db.StringProperty() password = db.StringProperty() mobile = db.StringProperty() is_authenticated = db.BooleanProperty() groupid = db.StringProperty() mobilesynched = db.BooleanProperty() devicemodel = db.StringProperty() isatmoscast = db.BooleanProperty() registerdate = db.DateProperty(auto_now_add=True) pack = db.StringProperty() personalcontact = db.BooleanProperty() lastlogin = db.DateProperty(auto_now_add=True) isactive = db.BooleanProperty() feeds = db.ListProperty(db.Key) </code></pre> <p>This works fine:</p> <pre><code>if blog.key() not in user.feeds: user.feeds.append(blog.key()) user.put() </code></pre> <p>This throws the error:</p> <pre><code>if post.key() not in blog.posts: blog.posts.append(post.key()) blog.put() </code></pre> <p>Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload