【发布时间】:2017-04-30 00:50:19
【问题描述】:
我想计算年龄。我试过下面的代码...
DOB = models.DateField()
Age = models.IntegerField(max_length= 2, default= date.today().year - DOB.year)
我有错误
AttributeError: 'DateField' object has no attribute 'year'
如何从 DateField 中获取年份值..
【问题讨论】:
标签: django python-2.7 python-3.x django-models