From 9b022693613915a75ad9e0b0cd9e7f05e1747556 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 21 Mar 2012 20:56:57 +0100 Subject: [PATCH] ips without city --- pandora/user/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora/user/models.py b/pandora/user/models.py index 401a9bc8..8b9a7d8c 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -61,10 +61,13 @@ class SessionData(models.Model): g = GeoIP() location = g.city(self.ip) if location: - city = location['city'].decode('latin-1') country = ox.get_country_name(location['country_code']) - self.location = u'%s, %s' % (city, country) - self.location_sort = u'%s, %s' % (country, city) + if location['city']: + city = location['city'].decode('latin-1') + self.location = u'%s, %s' % (city, country) + self.location_sort = u'%s, %s' % (country, city) + else: + self.location_sort = self.location = country else: self.location_sort = self.location = None except: