I have the following lazy relationship in my SQLAlchemy model:
class AuthorModel(db.Model):
books = db.relationship("BookModel", backref="authors", lazy=True)
def bookCount(self):
return self.books.count()
I would like to get books count of the author but instead I get the following error:
TypeError list.count() takes exactly one argument (0 given)
Any advice and insight is appreciated.
return len(list(self.books))
wroks for me. Thanks.