[Answer]-Date Query in Django

1đź‘Ť

âś…

from datetime import datetime, timedelta

result = A.objects.filter(date_sent__lt=datetime.date.today() - timedelta(days=1))
👤pkacprzak

0đź‘Ť

If A is the name of your class, I think you have to call A.objects.get first:

A.objects.get(
   Q((date_sent - datetime.now()).days > 1)
)

“Making queries” from the Django documentation

👤Talvalin

Leave a comment