Opened 5 years ago
Closed 5 years ago
#31023 closed Bug (needsinfo)
__second lookup doesn't work on Django 2.2.7.
Reported by: | Ismael Jerez | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.2 |
Severity: | Normal | Keywords: | query, filter, datetimefield, second |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (1)
comment:1 by , 5 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Summary: | Filtering DatetimeField by second not working on Django 2.2.7 (it works on Django 1.10) → __second lookup doesn't work on Django 2.2.7. |
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 time zone definitions in the database. Can you provide more details or a sample project?