From 5abe649b7ff1a7d0314dd4154f155583ce233ac8 Mon Sep 17 00:00:00 2001 From: josecsotomorales Date: Thu, 14 Mar 2024 18:08:51 -0400 Subject: [PATCH] Add timezone to timestamp models --- sqlalchemy_utils/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlalchemy_utils/models.py b/sqlalchemy_utils/models.py index 81fa4541..66529fa0 100644 --- a/sqlalchemy_utils/models.py +++ b/sqlalchemy_utils/models.py @@ -22,8 +22,8 @@ class SomeModel(Base, Timestamp): id = sa.Column(sa.Integer, primary_key=True) """ - created = sa.Column(sa.DateTime, default=datetime.now(timezone.utc), nullable=False) - updated = sa.Column(sa.DateTime, default=datetime.now(timezone.utc), nullable=False) + created = sa.Column(sa.DateTime(timezone=True), default=datetime.now(timezone.utc), nullable=False) + updated = sa.Column(sa.DateTime(timezone=True), default=datetime.now(timezone.utc), nullable=False) @sa.event.listens_for(Timestamp, 'before_update', propagate=True)