From 546e422e645e2f47f11d1557b15eff3204b31659 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 12 Feb 2022 13:56:07 +0100 Subject: [PATCH] Ensure some values exist before updating them Signed-off-by: Yohann D'ANELLO --- apps/member/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/member/models.py b/apps/member/models.py index 9cb0cbde..89be7a3a 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -264,10 +264,12 @@ class Club(models.Model): today = datetime.date.today() if (today - self.membership_start).days >= 365: - self.membership_start = datetime.date(self.membership_start.year + 1, - self.membership_start.month, self.membership_start.day) - self.membership_end = datetime.date(self.membership_end.year + 1, - self.membership_end.month, self.membership_end.day) + if self.membership_start: + self.membership_start = datetime.date(self.membership_start.year + 1, + self.membership_start.month, self.membership_start.day) + if self.membership_end: + self.membership_end = datetime.date(self.membership_end.year + 1, + self.membership_end.month, self.membership_end.day) self._force_save = True self.save(force_update=True)