Problems filtering django datetime field by month and day

前端 未结 4 878
渐次进展
渐次进展 2020-12-05 13:52

Can someone explain to me why the following filters are not working at the month and day level? Filtering by year seems to work, but not the other two.

>         


        
4条回答
  •  不知归路
    2020-12-05 14:44

    I was seeing exactly the same behaviour as you.

    If you check the documentation for 1.6 and the month queryset. They have added the following paragraph:

    "When USE_TZ is True, datetime fields are converted to the current time zone before filtering. This requires time zone definitions in the database."

    If you change the following line in your settings to False, then you should start getting the data back that you're expecting.

    USE_TZ = False
    

提交回复
热议问题