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)))
精彩评论