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
Post a Comment