#24076: Query may fail with pytz exception
-------------------------------+------------------------------------
Reporter: lvella | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by aaugustin):
* component: Database layer (models, ORM) => Documentation
* stage: Unreviewed => Accepted
Comment:
Thanks for the proposal. Unfortunately it won't work on databases other
than PostgreSQL because they store datetimes in UTC. As a consequence
they're vulnerable to the effect I described in question 3 in the
[https://docs.djangoproject.com/en/1.7/topics/i18n/timezones/#troubleshooting
timezone troubleshooting FAQ].
I considered this issue carefully when I implemented support for time
zones in Django 1.4. I was aware of the points you're making. I decided
that forbidding mixing dates and datetimes outright was too extreme. It
would require many changes in projects that work just fine because they
never see datetimes during the DST switch.
It's the left-hand-side of a lookup that determines the type, not the
right-hand-side. Therefore the correct solution is to implement an
explicit `__date` lookup i.e. #9596. That's the opposite of what you
requested when you filed the ticket but that also what you recommended in
your last comment:
> the database type should be converted to date, dropping the time
information in the process
This solution requires timezone conversion of datetimes in the database
but it shouldn't be an issue as it already exists to support the `dates()`
and `datetimes()` queryset methods.
I'm going to requalify this as a documentation issue because comparing
dates with datetimes is probably a common error and I don't think the docs
warn against it. I don't know where the warning should be added, though.
--
Ticket URL: <https://code.djangoproject.com/ticket/24076#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.b982b60950f5bd4f54ff74cf6851910e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.