#29726: Setting the Shanghai time zone causes a query error
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  AberSheeran                        |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I have a little website. It's settings.py like this

 {{{
 LANGUAGE_CODE = 'en-us'

 TIME_ZONE = 'Asia/Shanghai'

 USE_I18N = True

 USE_L10N = True

 USE_TZ = True
 }}}

 And then, I had saved some data in SQLite3. But get a error


 {{{
 >>> for each in Message.objects.all():
 ...     print(each.create_time.year, each.create_time.month)
 ...
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 2018 8
 >>> for each in Message.objects.filter(create_time__year="2018",
 create_time__month="09"):
 ...     print(each.create_time.year, each.create_time.month)
 ...
 2018 8
 2018 8
 2018 8
 >>>
 }}}

 These three messages were sent in the last eight hours of August 31, 2018
 UTC. The result of querying through .all() is UTC time. But the result of
 querying through .filter() is Asia/Shanghai time. This brings me some
 trouble...

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29726>
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/054.3835e164f3ed2f7ebf1b20bfb24082d6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to