6👍
✅
You filter with:
from datetime import timedelta
from django.db.models.functions import Now
Product.objects.filter(
status="PENDING", created__lt=Now()-timedelta(hours=1)
).order_by('-created')
0👍
Also, you can use the below query for this purpose:
from django.utils import timezone
now = timezone.now()
one_hour_ago = now - timezone.timedelta(hours=1)
Product.objects.filter(status="PENDING", created__lt=one_hour_ago).order_by('-created')
- [Django]-Good ways to import data into Django
- [Django]-Display field other than __str__
- [Django]-Excluding password when extending UserCreationForm
- [Django]-Django Gunicorn: Unable to find application
- [Django]-Running django application via SSH on Windows
Source:stackexchange.com