diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 8770db8..60cb799 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -545,7 +545,7 @@ class Tournament(models.Model): def last_started_match(self): matches = [m for m in self.all_matches(False) if m.start_date] matches.sort(key=lambda m: m.start_date, reverse=True) - return matches.get(0) # get returns None if not present + return matches[0] if matches else None def round_for_index(self, index): return self.round_set.filter(index=index, parent=None).first() @@ -553,7 +553,7 @@ class Tournament(models.Model): def first_round(self): main_rounds = list(self.round_set.filter(parent=None)) main_rounds.sort(key=lambda r: r.index, reverse=True) - return main_rounds.get(0) # get returns None if not present + return main_rounds[0] if main_rounds else None def broadcasted_group_stages_matches(self): matches = []