From d8e9f7079322885b904f34da4b9d795507d62a6e Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Tue, 4 Sep 2018 21:46:55 -0400 Subject: [PATCH] Fix failing geoip searching on the homepage for unauthenticated users --- get_together/views/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/get_together/views/__init__.py b/get_together/views/__init__.py index 9d724a3..a821d98 100644 --- a/get_together/views/__init__.py +++ b/get_together/views/__init__.py @@ -77,11 +77,12 @@ def home(request, *args, **kwards): else: city = sorted(nearby_cities, key=lambda city: location.city_distance_from(ll, city))[0] - if request.user.profile.city is None: + if request.user.is_authenticated and request.user.profile.city is None: profile = request.user.profile profile.city = city profile.save() - except: + except Exception as err: + print("City lookup failed", err) raise Exception('City lookup filed') else: raise Exception('Geocoder result has no latlng')