[Django] #31023: Filtering DatetimeField by second not working on Django 2.2.7 (it works on Django 1.10)

3 views
Skip to first unread message

Django

unread,
Nov 22, 2019, 7:08:10 AM11/22/19
to django-...@googlegroups.com
#31023: Filtering DatetimeField by second not working on Django 2.2.7 (it works on
Django 1.10)
-------------------------------------+-------------------------------------
Reporter: Ismael | Owner: nobody
Jerez |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) | Keywords: query, filter,
Severity: Normal | datetimefield, second
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi:

I recently update Django from version 1.10 to 2.2.7.

I have a query filtering like this:

{{{ MyModel.objects.filter(a_datetimefield__second=4).all() }}}

This returns me an empty QuerySet result.

But, If I try something like this just for testing:

{{{
MyModel.objects.filter(a_datetimefield__second_icontains='4').first().a_datetimefield.second
}}}

It returns {int} 4 !!!

I tried this too:

{{{ MyModel.objects.filter(a_datetimefield__second_exact=4).all() }}}

And the results is the same (empty QuerySet instance)

Using hour or minute works perfect, it only happens with second attribute.


Thanks in advance,
Ismael.

--
Ticket URL: <https://code.djangoproject.com/ticket/31023>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 22, 2019, 8:01:58 AM11/22/19
to django-...@googlegroups.com
#31023: __second lookup doesn't work on Django 2.2.7.
-------------------------------------+-------------------------------------
Reporter: Ismael Jerez | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: query, filter, | Triage Stage:
datetimefield, second | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => needsinfo


Comment:

Thanks for this report, however I'm not able to reproduce this issue. If
you use `USE_TZ = True` then it can be related with the lack of
[https://docs.djangoproject.com/en/2.2/ref/models/querysets/#database-
time-zone-definitions time zone definitions in the database]. Can you
provide more details or a sample project?

--
Ticket URL: <https://code.djangoproject.com/ticket/31023#comment:1>

Reply all
Reply to author
Forward
0 new messages