gte 仅显示本月(等于)且不大于的对象

gte is only showing objects for this month (equal to) and not greater than

我将尝试在不暴露客户数据的情况下向您展示此内容

查询:

Booking.objects.filter(startTime__year__gte=2020, startTime__month__gte=7,startTime__day__gte=27, depositPaid=True).order_by('startTime')

这应该会显示从 7 月 27 日开始的所有预订,包括 7 月 27 日和以后的所有预订。但是,界限是在第 8 个月。 None 的 8 月预订显示。

如果我运行:

Booking.objects.filter(startTime__year__gte=2020, startTime__month__gte=8,startTime__day__gte=1, depositPaid=True).order_by('startTime')

然后我确实得到了 8 月份的所有预订。我不明白为什么 startTime__month__gte=7 不显示八月。

day__gte=27 过滤只会 return 得到当月第 27 天或更大的结果,无论月份是什么,8 月的日期小于 27 的日期都不会returned.

如果您想在特定日期之后过滤结果,您应该将其作为对列的单个查询来执行,而不是作为对日期部分的单独查询。

import datetime
Booking.objects.filter(startTime__gte=datetime.date(2020, 7, 27), depositPaid=True).order_by('startTime')