【发布时间】:2021-12-08 00:28:39
【问题描述】:
我想显示一个即将到来的生日列表,剩余天数为 30 天。
示例:
| Name | Date Of Birth | Remaining Days |
|---|---|---|
| John Die | 2050-10-25 | 4 Days Left |
| John Snow | 2050-10-26 | 5 Days Left |
我不知道如何计算剩余天数,但我尝试了这段代码,但出现错误“无法减去偏移天真和偏移感知日期时间”
customer=Customer.objects.filter()[:10]
for i in customer:
remaining = i.dateOfBirth - datetime.today()
print(remaining)
【问题讨论】:
标签: python django django-rest-framework