We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b905810 commit d28d9daCopy full SHA for d28d9da
backend/PyMatcha/models/user.py
@@ -193,10 +193,13 @@ def to_dict(self) -> Dict:
193
returned_dict.pop("password")
194
returned_dict.pop("previous_reset_token")
195
196
- today = datetime.datetime.utcnow()
197
- returned_dict["age"] = (
198
- today.year - self.birthdate.year - ((today.month, today.day) < (self.birthdate.month, self.birthdate.day))
199
- )
+ if self.birthdate:
+ today = datetime.datetime.utcnow()
+ returned_dict["age"] = (
+ today.year
200
+ - self.birthdate.year
201
+ - ((today.month, today.day) < (self.birthdate.month, self.birthdate.day))
202
+ )
203
return returned_dict
204
205
@classmethod
0 commit comments