diff --git a/postcards/models.py b/postcards/models.py index 78087d0..72ea20d 100644 --- a/postcards/models.py +++ b/postcards/models.py @@ -211,8 +211,9 @@ def save(self, *args, **kwargs): location = geolocator.geocode(location_string) logger.info(f"Geocoding: {location_string}") - self.latitude = str(location.latitude) - self.longitude = str(location.longitude) + if location is not None: + self.latitude = str(location.latitude) + self.longitude = str(location.longitude) except Exception as e: logger.warning("Warning in geocoding a Person: " + str(e) + str(self)) super().save(*args, **kwargs)