4👍
✅
You need to use F expressions for this query.
Your query would look the following way:
products = Product.objects.filter(
Q(delivery_date__lte=(datetime.datetime.now() + timedelta(days=F('contract__safety_days'))))
)
Source:stackexchange.com