Answer the question
In order to leave comments, you need to log in
Schedule background task for django model?
There is a model in which, depending on the current time, you need to update one status field
class Rfis(models.Model):
RFI_STATUS = (
("Created", "Created"),
("Opened", "Opened"),
("Issued", "Issued")
)
rfi_status = models.CharField(max_length=50, choices=RFI_STATUS, default="Created")
rfiid = models.CharField(max_length=4, primary_key=True)
active = models.BooleanField(default=True)
issue_datetime = models.DateTimeField(blank=True, null=True)
open_datetime = models.DateTimeField(blank=True, null=True)
close_datetime = models.DateTimeField(blank=True, null=True)
timestamp = models.DateTimeField(auto_now_add=True)
Answer the question
In order to leave comments, you need to log in
You can write a management command and run it with cron . Although I would look in the direction of changing the logic so that I don’t have to change the data on the timer at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question