I want to update the user last seen column. To do that i am trying 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 that run always when the user execute some action.
@mod.before_app_request
def before_request():
current_user.ping()
This is the error:
TypeError: can't compare offset-naive and offset-aware datetimes
How can i solve this? I am using postgres and the problem is easily simulated with the code that i am showing.