From 85c13033e895b5824f0941b887c48e068ad9d2ce Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 8 Mar 2021 11:56:17 +0000 Subject: [PATCH] fix: account for org with no answers when get name --- people/models/organisation.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/people/models/organisation.py b/people/models/organisation.py index 7b7094c..3874425 100644 --- a/people/models/organisation.py +++ b/people/models/organisation.py @@ -43,7 +43,13 @@ class Organisation(models.Model): def __str__(self) -> str: # Prefer name as in latest OrganisationAnswerSet - return self.current_answers.name or self.name + try: + name = self.current_answers.name + + except AttributeError: + name = '' + + return name or self.name @property def current_answers(self) -> 'OrganisationAnswerSet':