开发者

Django QuerySet next date

开发者 https://www.devze.com 2023-01-04 04:05 出处:网络
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 decemb

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

精彩评论

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