Django会根据其重复频率每周,每月或每年自动重新发布数据

在我的django项目中,我试图根据其重复频率重新发布记录,该频率可以是每天,每周,每月等。假设某条记录今天发布并且其重复出现频率是每周,我希望该记录继续出现创建之前一周的“天”和“时间”为基础的每周一次,依此类推,也就是说,旧记录将是新记录,而其他记录的顶部将根据重复出现的频率比其早。

models.py

class Menu(models.Model):
    none = 0
    Daily = 1
    Weekly = 7
    Monthly = 30
    Quarterly = 90
    SemiAnual = 180
    Yearly = 365

    Frequency_Of_Reocurrence = (
        (none, "None"),
        (Daily, "Daily"),
        (Weekly, "Weekly"),
        (Monthly, "Monthly"),
        (Quarterly, "After 3 Months"),
        (SemiAnual, "After 6 Months"),
        (Yearly, "After 12 Months")
    )
    vendor = models.ForeignKey(Vendor, on_delete=models.CASCADE)
    name = models.CharField(verbose_name="food name", null=False, blank=False, max_length=100)
    description = models.TextField(verbose_name="Food Description", max_length=350, null=False, blank=False)
    image = models.ImageField(upload_to=user_directory_path, default='veggies.jpg')
    isrecurring = models.BooleanField(default=False)
    frequencyofreocurrence = models.IntegerField(choices=Frequency_Of_Recurrence)
    datetimecreated = models.DateTimeField(verbose_name='date-time-created', auto_now_add=True)

我如何才能真正实现我在视图中要执行的操作。

提前致谢。

评论