On 03/03/2012, at 4:10 AM, Scott Macri wrote:

> I'm trying to figure out the best way to create an automated in a
> python/django web application.  My intention is to send an email
> message in the future based on the given future date/time.  What is
> the best approach to do this?
> 
> I was thinking of creating a cron job and a python script, but I would
> rather have the process be part of my django application so I don't
> have to worry about extra stuff.
...
> Any thoughts on how to handle this situation?  Thanks.

Yeah - use a cron job and a Python script :-)

Seriously -- Django is good at what it does, but just because you've got a 
really good hammer, it doesn't mean every problem is a nail. The task you 
describe sounds like almost exactly what cron scripts are designed to handle. 
Rather than trying to bend Django into a shape that will solve your problem, 
use the right tool for the job.

You might also be able to attack the problem using a task queue like celery 
[1]. However, celery is more complex to get set up than a cron script. There 
are lots of benefits that come with that complexity, but if you just want to 
get something going, you don't have any experience with task queues, and you're 
not expecting any serious load problems, cron will be the easier option.

It's also worth pointing out that you can still use parts of Django (e.g., your 
models, the ORM, the mail sending utilities) in a standalone Python script that 
is called by cron/celery. Django is a just a set of Python libraries. Yes, it's 
a set of libraries that is usually used to build web sites, and most examples 
use Django APIs to service HTTP requests, but there's no reason you can't write 
a standalone Python script that uses Django's APIs to access and manipulate 
data.

[1] http://celeryproject.org/

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to