First create a custom management command, for example:
class Command(BaseCommand):
commands = ['sendreport',]
args = '[command]'
help = 'Send report'
def handle(self, *args, **options):
'''
Get completed sessions, send invite to vote
'''
reports = Log.objects.filter(date__gt=datetime.today(),date__lt=(datetime.today()+timedelta(days=2)))
for report in reports:
send_notification(_("Report"), _("log:%s")%report.text, 'my@email.com' )
To create an email text and send
Then you can add a cronjob, something like
0 0 * * * /pathtovirtualenv/python manage.py sendreport
Run this command every night
source
share