django日期字段查询操作
# 1. lt:小于
queryset = YouModel.objects.filter(时间字段名称__lt=start)
# 2. lte:小于等于
queryset = YouModel.objects.filter(时间字段名称__lte=start)
# 3. gt:大于某个时间
查询前一天数据
now = datetime.datetime.now()
start = now – datetime.timedelta(hours=23, minutes=59, seconds=59)
start = now+datetime.timedelta(day=-1)
queryset = YouModel.objects.filter(时间字段名称__gt=start)
# 4. gte:大于等于某个时间
queryset = YouModel.objects .filter(时间字段名称__gte=start)
# 5. year:查询某年
YouModel.objects.filter(时间字段名称__year=2005)
# 6. month:查询某月
YouModel.objects.filter(时间字段名称__month=12)
# 7. day:某天
YouModel.objects.filter(时间字段名称__day=3)
# 8. week_day:星期几
YouModel.objects.filter(时间字段名称__week_day=2)
# 9. range:查询时间段
start_date = datetime.date(2005, 1, 1)
end_date = datetime.date(2005, 3, 31)
YouModel.objects.filter(时间字段名称__range=(start_date, end_date))