Best way to change a django model field automatically after a certain amount of time?

Viewed 32

Im creating an escrow-like service and I need to send emails to customers so they can verify if they have received the package after a certain amount of time after their purchase. I have an order class with an "funds_unlocked" boolean attribute. It can only be set to TRUE if the customer is happy with his product (aka he sets it to TRUE) or if 2 weeks go by and the customer hasn't responded. Then the "funds_unlocked" attribute automatically gets set to TRUE and the account balance of the vendor increases. How can I automatically send emails to the customer and automatically change the field to TRUE after 2 weeks?

class Order(models.Model):
    funds_unlocked = models.BooleanField(default=False)
    
    def save(self, *args, **kwargs):
     //  if (old order funds_unlocked = False) and (new order funds_unlocked = True):
     //    increase Balance of vendor

Are there other/easier ways than doing it with celery? How would you do this?

Thanks in advance

1 Answers
Related