开发者

Django query a model since its creation to an X time

Having a such model:

class HelpRequest(models.Model):
    creation_tim开发者_如何学Pythone = models.DateTimeField(auto_now_add=True)

I want to query HelpRequest which are created within the last 5 mins, how can I achieve this?


import datetime
HelpRequest.objects.filter(creation_time__gte=(datetime.datetime.now() - datetime.timedelta(minutes=5)))
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜