krzyhub
krzyhub

Reputation: 6540

Django - replacing year in DateTimeField

With this:
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?

Upvotes: 1

Views: 2130

Answers (1)

John
John

Reputation: 5206

The correct line is:

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

date.year is a method not a attribute

datetime.date.today

Upvotes: 3

Related Questions