diff --git a/ami/main/models.py b/ami/main/models.py index e144a82f0..1f5c64f7a 100644 --- a/ami/main/models.py +++ b/ami/main/models.py @@ -515,7 +515,7 @@ def duration_label(self) -> str: If duration was populated by a query annotation, use that otherwise call the duration() method to calculate it. """ - duration = self.duration if isinstance(self.duration, datetime.timedelta) else self.duration() + duration = self.duration() if callable(self.duration) else self.duration return ami.utils.dates.format_timedelta(duration) # These are now loaded with annotations in EventViewSet @@ -1475,7 +1475,7 @@ def duration_label(self) -> str | None: If duration has been calculated by a query annotation, use that value otherwise call the duration() method to calculate it. """ - duration = self.duration if isinstance(self.duration, datetime.timedelta) else self.duration() + duration = self.duration() if callable(self.duration) else self.duration return ami.utils.dates.format_timedelta(duration) def detection_images(self, limit=None):