AP257
AP257

Reputation: 93793

Django: query database at fixed interval and send email?

I have a Django site and once a week, I'd like to query the database and send an email based on that query.

It's a library site, and I want to query the list of users, find each user's checked-out books, and email each user.

The process is something like this (pseudocode):

for user in users:
    get user.email_address
    get user.books
    get intro_text and from_address (global for the site)
    create email for user
    send email

There's also the complication that intro_text and from_address need to be configurable through the admin interface. I'm planning to store these in the database, rather than in settings.py.

I'm guessing I should create this as a Django management task that I can then run as a cron job - would that be a sensible approach?

Thanks for your help.

Upvotes: 2

Views: 500

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599590

Yes, management task + cron job is the way to go here.

Upvotes: 1

Related Questions