Issue
I was wondering, is there a problem to call a function in order to generate a default value such as the current time when we want to define a column in our database model? I would be appreciated it if someone helps me with my problem.
Solution
There is no problem, in fact it's often quite handy:
class Item(db.Model):
created = db.Column(db.DateTime)
def __init__(self):
self.created = datetime.utcnow()
Answered By - dmitrybelyakov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.