From 72a6b091e6f53e11798decf2fa4365ccfd4eef50 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 25 Jul 2023 22:14:13 +0300 Subject: [PATCH] make more robust --- core/models/caves.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/models/caves.py b/core/models/caves.py index 5bef08c..0d94b4c 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -318,9 +318,12 @@ class Entrance(TroggleModel): except: stations = SurvexStation.objects.filter(name = station) print(f" # MULTIPLE stations found with same name '{station}' in Entrance {self}:") - for s in stations: - print(f" # {s.id=} - {s.name} {s.latlong()}") # .id is Django internal field, not one of ours - return stations[0] + if len(stations) > 1: + for s in stations: + print(f" # {s.id=} - {s.name} {s.latlong()}") # .id is Django internal field, not one of ours + return stations[0] + else: + return None def exact_location(self): return self.single(self.exact_station)