Search code examples
pythonflask-sqlalchemymarshmallowflask-marshmallow

TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'str'


I have a table with some columns which one of theme is 'date' type and is defined as below in sqlalchemy model class:

 ConfStartDate = db.Column(Date, nullable=False)

python gives me error "TypeError: descriptor 'isoformat' requires a 'datetime.date' object but received a 'str'" when wants to read all and serializes the output using these codes:

papers = Paper.query.order_by(Paper.PaperID).all()
paper_schema = PaperSchema(many=True)
data = paper_schema.dump(papers)
return data 

How can I pass this error?


Solution

  • I changed default value from '0000-00-00-' to NULL As Lucas Scott mentioned in comments and the problem get solved.