在试图使用 `models.objects.filter(create_time__month=month)` 找出一个月的文章时,发现返回的QuerySet为空集,最终在stackoverflow找到了[答案](https://stackoverflow.com/questions/21918802/problems-filtering-django-datetime-field-by-month-and-day)
django文档中解释:
```"When USE_TZ is True, datetime fields are converted to the current time zone before filtering. This requires time zone definitions in the database."```
应在settings中关闭USE_TZ: `USE_TZ = False`
之后才发现我之前的博客时间都提早8小时,就是这个原因。
django文档中解释:
```"When USE_TZ is True, datetime fields are converted to the current time zone before filtering. This requires time zone definitions in the database."```
应在settings中关闭USE_TZ: `USE_TZ = False`
之后才发现我之前的博客时间都提早8小时,就是这个原因。