manch manch - 10 months ago 40
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?


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.