给定今天过滤 Django 条目的日期范围:
today_min = datetime.datetime.combine(timezone.now(), datetime.time.min)
today_max = datetime.datetime.combine(timezone.now(), datetime.time.max)
today_events = Entry.objects.filter(due_date_time__range=(today_min, today_max))
为了考虑时区支持,我显然使用timezone.now()
而不是,但我仍然收到错误消息:datetime.date.today()
RuntimeWarning: DateTimeField received a naive datetime (2013-01-13 00:00:00) while time zone support is active.
RuntimeWarning: DateTimeField received a naive datetime (2013-01-13 23:59:59.999999) while time zone support is active.
我在看什么?谢谢