File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
user_sessions/templatetags Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11Release Notes
22=============
33
4+ 1.5.2
5+ -----
6+ * Also work with GeoIP2 country database
7+
481.5.1
59-----
610* Updated documentation for GeoIP2 library
Original file line number Diff line number Diff line change @@ -98,12 +98,16 @@ def location(value):
9898 """
9999 try :
100100 location = geoip () and geoip ().city (value )
101- if location and location ['country_name' ]:
102- if location ['city' ]:
103- return '{}, {}' .format (location ['city' ], location ['country_name' ])
104- return location ['country_name' ]
105101 except Exception as e :
106- warnings .warn (str (e ))
102+ try :
103+ location = geoip () and geoip ().country (value )
104+ except Exception as e :
105+ warnings .warn (str (e ))
106+ location = None
107+ if location and location ['country_name' ]:
108+ if 'city' in location :
109+ return '{}, {}' .format (location ['city' ], location ['country_name' ])
110+ return location ['country_name' ]
107111 return None
108112
109113
You can’t perform that action at this time.
0 commit comments