manch manch - 1 year ago 82
Python Question

Best way to trigger a function when DateField in model expires

I have a "Contest" model that a user creates and one of the fields is

(endTime = models.DateField(

I need a method to run a function when their contest has expired. The function would be to notify users, update objects, etc.

What would be the best method to achieve this?

Answer Source

To schedule a task you can look here

as for a this question,

procedure to identify that the datetime field has passed

This would work:


So you would have a task running continuously that would call a django command every X hours, that would use the above search to find any expired contests.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download