I'm using Flask SQLAlchemy models to make a database for my app, and I'm trying to query the database using models.Posts.query.all() This is my model:
class Posts(db.Model):
post_id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(500), index=True)
date = db.Column(db.Date)
image = db.Column(db.String(500))
post_body = db.column(db.String(10000),index=True)
authors = db.relationship('Users', backref='authors', lazy='dynamic')
def __repr__(self):
return '' % (self.post_id, self.title, self.date, self.image)
And this is the error message I get:
>>> models.Posts.query.all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/lisa-jd/Blog_platform/app/models.py", line 30, in __repr__
image = db.Column(db.String(50))
TypeError: not all arguments converted during string formatting
Any help would be very appreciated.
image = db.Column(db.String(50))is missing. `