I am using Django 3.2
I have a model like this:
class FoodItem(models.Model):
display_date = models.DateTimeField()
expiry_date = models.DateTimeField()
safe_to_eat_days_after_expiry = models.PositiveSmallIntegerField()
# ...
I want to run a query to get all items that have expired, but are still safe to eat.
This is what I have so far:
criterion1 = Q(expiry_date__gt=date.today())
criterion2 = Q(???) # expiry_date +timedelta(safe_to_eat_days_after_expiry ) <= date.today()
FoodItem.objects.filter(criterion1 & criterion2)
How do I implement this?