4👍
✅
You can calculate the datetime for 24 hours ago and then do a gte
query against that.
from datetime import datetime, timedelta
target_time = datetime.now() - timedelta(hours=24)
my_items = MyModel.objects.filter(obj_time__gte=target_time)
Source:stackexchange.com