【发布时间】:2017-08-25 11:42:58
【问题描述】:
任何人都可以建议我如何比较 django-admin 中的两个日期字段 我是管理员,我想说,每当我更新日期字段的日期时,另一个日期字段也必须更改(比第一个日期字段多 30 天),如果第二个日期字段更改,我想在 django 中更改另一个字段管理页面! 提前谢谢
STATUS_CHOICES = (
('P', 'Paid'),
('U', 'UNPAID'),
)
class Users(models.Model):
status = models.CharField(max_length=1, choices=STATUS_CHOICES , default="U")
updated = models.DateTimeField(default=now)
expiry = models.DateTimeField(default=updated_plus_30_days())
# updated_plus_30_days():
# if updated = "12/8/2017" and expiry is equal to "12/09/2017" and then i changed
# the updated field to be equal to "12/12/2017" then expiry have to equal to "12/1/2018"
# if the updated field is >= than expiray then expiray have to increase one month and check
# if status is == p:
# status = u
# else :
# status = u
【问题讨论】: