开发者

Django QuerySet next date

My model has a DateField. If I wi开发者_Python百科sh to retrive all data that have a date after today, how will it be constructed? Eg. retreive all field with dates after today and stop at 31st december

today = datetime.date.today

Object.object.filter(date__day != today)

or will it be done using exclude?


If I understood what you are trying to do, you should simply be able to filter like this:

today = datetime.date.today()
Object.objects.filter(date__gt=today, date__year=today.year)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜