开发者

Django - replacing year in DateTimeField

With this:

开发者_StackOverflow mb = self.birthdate.replace(year=date.today.year)

It gives this:

Caught AttributeError while rendering: 'builtin_function_or_method' object has no attribute 'year'

It is possible to replace year?


The correct line is:

mb = self.birthdate.replace(year=date.today().year)

date.year is a method not a attribute

datetime.date.today

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜