有一个model的字段是
DateTimeField
,我现在要具体查询某一天date
的数据,应该怎么用orm来查询呢?
指定年月日
YourModel.objects.filter(datetime_published__year='2008',
datetime_published__month='03',
datetime_published__day='27')
- 1
- 2
- 3
字符串匹配
YourModel.objects.filter(your_datetime_field__startswith=datetime.date(2009,8,22))
- 1
字符串包含
Mymodel.objects.filter(date_time_field__contains=datetime.date(1986, 7, 28))
- 1