I should first mention that I\'m using SqlAlchemy through Flask-SqlAlchemy. I don\'t believe this affects the issue but if it does, please let me know.
Here is the relev
Set the import out the class.
from datetime import datetime
last_updated = db.Column(db.DateTime, default=datetime.now())
or
import datetime
last_updated = db.Column(db.DateTime, default=datetime.datetime.now())
I did this
Look at your line:
last_updated = db.Column(db.DateTime, default=datetime.datetime.now)
There is no datetime.datetime.now
attribute in python. However, there is a datetime.datetime.now()
function in python. You were just missing a pair of parentheses.
last_updated = db.Column(db.DateTime, default=db.func.current_timestamp())
I think this will work
Try to use datetime.datetime.utcnow()
. This works for me.