I am relatively new to Django. I would like to send email notification fortnightly to the intended user. How do i do tat ? For example, user will enter their start date. Then i have to figure out the start date and make my app send notification FORTNIGHTLY from the start date until i stop this task. So which means the sending notification will vary according to the start date the users have entered.
Asked
Active
Viewed 537 times
0
-
You have many tools available to schedule tasks. You can use celery, cron job...https://stackoverflow.com/questions/573618/django-set-up-a-scheduled-job – Sandeep Balagopal May 30 '17 at 10:59
2 Answers
1
Use periodic tasks with celery that is the best option for send email notification.
@periodic_task(run_every=crontab(minute=0, hour='6'))
This will run the function every day on 6:00 AM For more details of schedules Refer http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedules

Community
- 1
- 1

Himanshu dua
- 2,496
- 1
- 20
- 27
-
but will this be doing the fortnight thing ? cause i have to implement notification on sending email fortnightly – May 30 '17 at 11:06
-
-
There is no explicit way of setting cron job to be fortnightly, it only has knowledge of days of the week/ days of the month. You can however test for odd/even weeks of the year in function body. – Tomasz Plaskota May 30 '17 at 11:11
0
The simple solution is to use your OS scheduler (like cron on unices) to execute a custom management command. You'll have to implement a way to store which users should get which mails so the management command can work it out. This works fine for the simplest cases but can become a mess very quickly...
The more complex solution is to use some async queue system (Celery is the usual culprit but there are alternatives).

bruno desthuilliers
- 75,974
- 6
- 88
- 118