From 22ac627f171ffdcd3bead3ee1a1402bce37e754d Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 2 Mar 2019 15:54:24 +0100 Subject: [PATCH] Fix str --- map/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/map/models.py b/map/models.py index 48a157d..6f432fa 100644 --- a/map/models.py +++ b/map/models.py @@ -37,7 +37,12 @@ class FriendLocation(BaseModel): return str(self.longitude) def __str__(self): - return f'{self.friend.get_display_name()} from {self.start_date} to {self.end_date}' + result = f'{self.friend.get_display_name()}' + if self.start_date: + result += f' from {self.start_date}' + if self.end_date: + result += f' until {self.end_date}' + return result @property def safe_html(self):