make more robust

This commit is contained in:
Philip Sargent 2023-07-25 22:14:13 +03:00
parent af552a3d62
commit 72a6b091e6

View File

@ -318,9 +318,12 @@ class Entrance(TroggleModel):
except: except:
stations = SurvexStation.objects.filter(name = station) stations = SurvexStation.objects.filter(name = station)
print(f" # MULTIPLE stations found with same name '{station}' in Entrance {self}:") print(f" # MULTIPLE stations found with same name '{station}' in Entrance {self}:")
for s in stations: if len(stations) > 1:
print(f" # {s.id=} - {s.name} {s.latlong()}") # .id is Django internal field, not one of ours for s in stations:
return stations[0] 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): def exact_location(self):
return self.single(self.exact_station) return self.single(self.exact_station)