django notify user three month before expire date

601 views Asked by At

I have a Django app that has an expiration date field where the user has to fill up when submitting the form. What I want to do next is to have a function that checks the expiration date and automatically sends an email notification to the user three months before the expiration date. I am not sure whether it is possible to do that or not. I did some reading on Django-notification but I am not sure what's the best way to approach this.

1

There are 1 answers

0
Priyanshu Panwar On

There are several methods to do this.

  • You can create a CRON Job to do this work, which is bit complex.
  • An easier way is to create a view function and run it once a day for all users or logged in user (if you have less than like 1000 users) once the homepage is loaded.
  • just check (request.user.exp_date - date.today()).days <= 90, then send mail.