python - SQLalchemy - 'AppenderQuery' object has no attribute 'serialize' -


so, i'm making json return property in 1 of classes, error when trying use 1 of properties:

class posts(base):     __tablename__ = 'posts'      post_id = column(integer, nullable = false, primary_key = true)     text = column(string, nullable = false)     date = column(datetime(timezone=true), server_default=func.now())     deleted = column(integer, default = 0)     owner = column(integer, foreignkey('users.id'))     owner_rel = relationship('users')     comments_rel = relationship('comments', cascade='all, delete-orphan', lazy='dynamic')      @property     def serialize(self):         # returns data object in proper format         return {             'postid': self.post_id,             'text': self.text,             'date': self.date,             'owner': self.owner,             'postowner': self.owner_rel.serialize,             'comments': self.comments_rel.serialize         }    class comments(base):     __tablename__ = 'comments'      comment_id = column(integer, nullable = false, primary_key = true)     post_id = column(integer, foreignkey('posts.post_id'))     post_rel = relationship('posts')     text = column(string, nullable = false)     date = column(datetime(timezone=true), server_default=func.now())     deleted = column(integer, default = 0)     owner = column(integer, foreignkey('users.id'))     owner_rel = relationship('users')      @property     def serialize(self):         # returns data object in proper format         return {             'commentid': self.comment_id,             'postid': self.post_id,             'text': self.text,             'date': self.date,             'ownerid': self.owner,             'owner': self.owner_rel.serialize         } 

and error - 'appenderquery' object has no attribute 'serialize'

help?


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -