4 | | When year and month lookup are chosen, if you have an event late in last day of the month that is first day of next month in UTC, queryset.dates method gives a date_hierarchy choice for next month 1st. |
5 | | It seems it can be solved modifiyng admin/contrib/templatetags/admin_list.py this way, using **queryset.filter and lists that may be very slow** : |
6 | | Needs importing: |
| 4 | Problem occures when : [USE_TZ, sqlite, DatetimeField ] AND object.datetime.date != object datetime.date(tzinfo=UTC), for example In America/Los_Angeles 2018-08-31, 11pm. |
| 5 | When year and month lookup are selected, queryset.dates method gives a date_hierarchy choice for next month 1st. |
| 6 | It may be solved modifying django/contrib/admin/templatetags/admin_list.py using **queryset.filter (instead of queryset.dates) and lists (that may be slow)** : |
32 | | If the month selected by date_hierarchy is the month of the DST, the objects of the last day of the month does not appear in the changelist. |
33 | | Changing the way "to_date" is set after ''elif month'' line 165 solves my problem: Instead of just adding 32 days with timedelta, I use make_aware with tzinfo=None. That way the to_date is set to the correct date and time. |
| 30 | In Europe/Paris timezone, on the October DST change, the **from_date + timedelta(days=32)).replace(day=1) ** used in django/contrib/admin/views/main.py to get next month's first day **does not select objects of October 31th**. They are not shown in the change list when October is selected through date_hierarchy. (steps to reproduce : sqlite, DateField, USE_TZ, TIMEZONE='Europe/Paris', Object date 2019-10-31 or 2018-10-31...). |
| 31 | It seems to be resolved by adding make_aware and tzinfo=None to to_date : |
| 32 | django/contrib/admin/views/main.py: |