#24076: Query may fail with pytz exception
----------------------------------------------+--------------------
     Reporter:  lvella                        |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.6
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 If I give date object as input to a filter on a DateTimeField field, like
 this:

 {{{
 class Ticket(models.Model):
     register_time = models.DateTimeField(auto_now_add=True)

 day = datetime.strptime('2014-10-19', '%Y-%m-%d').date()
 Ticket.objects.filter(register_time__gte=day)
 }}}

 I may get a pytz.exceptions.NonExistentTimeError exception. The exact
 exception was:

 pytz.exceptions.NonExistentTimeError: 2014-10-19 00:00:00

 This date is the start of DST in my timezone:

 {{{
 TIME_ZONE = 'America/Sao_Paulo'
 }}}

 I believe this is a bug because Django tries to convert my input to a
 datetime object before building the query, and in this case, this
 conversion yields an invalid datetime.

 This bug seems very related to issue #9596, because in these cases,
 datetime should be converted to date, not the opposite.

 A minimal showcase is attached. Unzip and run ./manage.py test

--
Ticket URL: <https://code.djangoproject.com/ticket/24076>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.8b424bb85678214eac3860338e7725b2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to