[Answered ]-Send weekly emails for a limited time after sign up in django

2πŸ‘

βœ…

The easiest way would be something like this:

  • Make a table e.g. challenge in database with following cols: challenge_name, week1, week2, …, as much weeks as you need. Make them nullable, so if some challenge is shorter, the rest of weeks can be null.
  • In users table (or you can make new one) add two cols, one for active challenge, the other for day started.
  • Then yes, you can run cron job daily, or maybe twice a day, in the morning and in the afternoon, that executes python function for sending mail. In that function you go through all users, check their current challenge, calculate the week they are in, query table challenge for mail content and then send.

I think this is the best solution, certainly the most simple and solid one πŸ™‚

πŸ‘€campovski

0πŸ‘

You definitely need to use cron task – I recommend Celery.
I think that you just need to build 12 templates (for every week, or maybe building less and use different parameters in the message) in your mailing service and name them with a format (for example {challenge_name}-{week_num}).
Every week when your cron task runs target the email message that you want to send by calculating the number weeks from the user registration date and planting it in your format to choose the correct email.

πŸ‘€shlomta1

Leave a comment