Closed seriaati closed 1 month ago
Looks like it is not just a sqlite issue. The aware datetime value is updated to be local explicitly when the record is loaded from the database https://github.com/tortoise/tortoise-orm/blob/0ddf8d327949be3ad812c41e4215c85b997214b9/tortoise/fields/data.py#L357
Django preserves the timezone value though. I'll look into it more later.
@seriaati actually Django converts a datetime to UTC on save too, see https://docs.djangoproject.com/en/5.1/topics/i18n/timezones/#overview
Tortoise mentions that the design of timezone is inspired by Django here but looks like the tortoise documentation is a bit misleading. It states that "When set use_tz = True, tortoise will always store UTC time in database no matter what timezone set" but it looks like it does so even if use_tz = False and timezone is not set.
I see, thanks for the answer! So then, what impact does use_tz
have on the storing of datetime data?
Describe the bug When I create a new object in a SQLite database, the timezone being put into the database, and the timezone being retrieved from the database, are different from the value I originally inputted.
To Reproduce
Result:
Expected behavior Expected result: