Here's my model,
class Question(models.Model):
...
timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)
How can I filter out the Questions asked in last 14 hours?
Thank You :)
from datetime import datetime, timedelta
time_threshold = datetime.now() - timedelta(hours=14)
results = Question.objects.filter(timestamp__lt=time_threshold)
by docs __lt means less than.