#31638: On Mysql/Sqlite, db.models.functions.Now uses wrong timezone
-------------------------------------+-------------------------------------
Reporter: Matthijs Kooijman | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* cc: Adam (Chainz) Johnson (added)
* status: new => closed
* resolution: => needsinfo
Comment:
HI Matthijs. Thanks for the report. Interesting.
I'm going to close this as needsinfo for now. It's not at all clear to me
what the correct path is. As such it probably needs some discussion on the
DevelopersMailingList.
I'll cc Adam, who know MySQL/MariaDB well enough to speak sensibly.
A few observations:
> With sqlite and USE_TZ=True: works, since Now() is in UTC and Django
defaults to UTC.
This seems to usual case. That's the one I'd hope would work. (And with
USE_TZ=True I'm not expecting too much...)
So contrast with MySQL:
> With Mysql and USE_TZ=True: fails, since Mysql uses the system timezone
(UTC+0200) and Django uses UTC.
Is this not bad behaviour from MySQL, or lacking some config setting? This
is your "For MySQL, you can change the session timezone (e.g. connection
timezone)." yes?
This would seem the most likely avenue to me at the moment.
Then, I'm not too keen on making `Now` cleverer. The whole point of the
functions in db.models that they proxy down transparently to what the DB
provides.
> For now, I'm going to switch to using timezone.now(),
I see the intention in using the DB function, but my initial thought
looking at the test case in the PR was "why not timezone.now() there?".
--
Ticket URL: <https://code.djangoproject.com/ticket/31638#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.ea4b31277bf999bfe9ec7d469c5c79d6%40djangoproject.com.