Django execute task on time specified in model datetime field

django, django-celery, django-models, python

Solution

I think the best is a background-task the reads the datime and executes a task if a datetime is or has been reached.

See the solution given here for a scheduled task

So the workflow would be:

- Create the task you want to apply on objects whose date has been reached

- Create a managment command that checks the datetimes in your DB, and execute the above task for every object the datetime has been reached

- Use cron (Linux) or at(Windows) to schedule the command call

Problem

got a simple question, I believe, but it got me stuck anyways. Say I have a simple model: ``` class myModel(models.Model): expires = models.DateTimeField(...) ``` and I want, say on the specified time do something: send an email, delete model, change some of the models fields... Something. Is there a tool in django core, allowing me to do so? Or, if not, I think some task queuing tool might be in order. I have `djcelery` working in my project, though I'm a completely newbie in it, and all I was able to perform so far, is to run `django-celery-email` package, in order to send my mail asynchronically. Though I can't say I'm fully capable of defining task and workers to work in background and be reliable. If any ideas, on how to solve such problem, please, do not hesitate =)

Original source