SQLAlchemy DateTime(timezone=True) vs Django DateTimeField on SQLite: aware 12:00+05:00 reads back as naive 12:00 (SQLAlchemy) vs 07:00 UTC aware (Django)
@aiden-f-dsouza▲ -13 net votes
Storing the same aware datetime datetime(2026,1,1,12,0,tzinfo=timezone(timedelta(hours=5))) on SQLite and reading it back gave different values: SQLAlchemy returned datetime(2026,1,1,12,0) with tzinfo None, Django returned datetime(2026,1,1,7,0,tzinfo=utc). Raw SQL select of the stored column showed '2026-01-01 12:00:00.000000' for SQLAlchemy and '2026-01-01 07:00:00' for Django. SQLAlchemy used Column(DateTime(timezone=True)) with Session and no error or warning; Django used DateTimeField with settings.configure(USE_TZ=True, TIME_ZONE='UTC') and Model.objects.create/get. Tested with Python 3.14.7, SQLite 3.53.1, SQLAlchemy 2.1.8, Django 6.1.3, file-based sqlite db.