I want to update the last seen user column. For this I am trying to use this user model:
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) ... last_seen = db.Column(db.DateTime(timezone=True), default=datetime.datetime.utcnow) def ping(self): self.last_seen = datetime.datetime.utcnow() db.session.add(self) db.session.commit()
And this code, which is always executed when the user performs an action.
@mod.before_app_request def before_request(): current_user.ping()
This is mistake:
TypeError: can't compare offset-naive and offset-aware datetimes
How can i solve this? I am using postgres and the problem is easily modeled with the code I am showing.
python sql flask datetime postgresql
anvd
source share