每年为所有用户重置模型中的值Django。

2024-05-04 12:48:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个Django应用程序来跟踪员工的假期。我不知道如何在每年的某个特定日期重新安排假期。对于如何做到这一点,是否有一些众所周知的解决方案/库

class User(models.Model):
avatar = models.ImageField(
    default='images/avatars/profile.png',
    upload_to=user_directory_path)
name = models.CharField(max_length=100)
title = models.CharField(max_length=200, default="Employee")
email = models.EmailField(max_length=254)
present = models.BooleanField(default=False)
code = models.CharField(max_length=4, unique=True)
date_created = models.DateTimeField(auto_now_add=True)
date_clocked = models.DateTimeField(default=timezone.now)
total_holiday = models.DecimalField(
    default=28.0, decimal_places=1, max_digits=4)
holiday_remaining = models.DecimalField(
    default=28.0, decimal_places=1, max_digits=4)

我的模型如上图所示,我需要在每年管理员用户定义的一天重置剩余的_假日字段


Tags: djangotruedefaultdatemodelslengthnowmax