I am new to SQLAlchemy and could not set the DateTime to create. I tried to use the default option, which can be found in many examples. I also tried to install it manually (I commented on it). So far they have not worked. Any help would be appreciated.
models.py import datetime from flask.ext.sqlalchemy import SQLAlchemy from werkzeug import generate_password_hash, check_password_hash db = SQLAlchemy() class User(db.Model): __tablename__ = 'users' uid = db.Column(db.Integer, primary_key=True) firstname = db.Column(db.String(40)) lastname = db.Column(db.String(40)) email = db.Column(db.String(120), unique=True) created = db.Column(db.DateTime, default=datetime.datetime.utcnow()) confirmed = db.Column(db.DateTime, nullable=True) pwdhash = db.Column(db.String(100)) def __init__(self, firstname, lastname, email, password): self.firstname = firstname.title() self.lastname = lastname.title() self.email = email.lower() self.set_password(password)
source share