Getting all items less than a month old

后端 未结 3 2065
北海茫月
北海茫月 2021-02-18 13:05

Is there a way to get all objects with a date less than a month ago in django.

Something like:

items = Item.objects.filter(less than a month old).order_b         


        
3条回答
  •  渐次进展
    2021-02-18 13:29

    items = Item.objects.filter(created_date__gte=aMonthAgo)
    

    Where aMonthAgo would be calculated by datetime and timedelta.

提交回复
热议问题