Null check for contact family names
This commit is contained in:
@@ -238,8 +238,13 @@ class Family(models.Model):
|
||||
raise ValidationError(f"Phone number {failed_numbers[0]} not valid")
|
||||
|
||||
def parent_names(self):
|
||||
a_name = self.contact_A.first_name
|
||||
b_name = self.contact_B.first_name
|
||||
a_name = ""
|
||||
b_name = ""
|
||||
if self.contact_A:
|
||||
a_name = self.contact_A.first_name
|
||||
if self.contact_B:
|
||||
b_name = self.contact_B.first_name
|
||||
|
||||
if a_name:
|
||||
if b_name:
|
||||
return f"{a_name} and {b_name}"
|
||||
|
||||
Reference in New Issue
Block a user