[Answer]-How can I subtract current DateTime from post time and make it fall within two conditions?

1👍

Well, you can use django F() expression,

from django.db.models import F
import datetime
now = datetime.datetime.now()
Photo.objects.filter(postTime__lte=now, 
                     postTime__gte=now - datetime.timedelta(minutes=60),
                     photo_poster__likes__gte=F(photo_poster__favorites) * 0.10,
                     photo_poster__likes__lte=F(photo_poster__favorites) * 1)

Leave a comment