mirror of
https://github.com/dolphin-emu/netplay-index.git
synced 2026-01-31 01:15:20 +01:00
util: Handle cases where a country may not have an iso_code
This commit is contained in:
@@ -12,7 +12,12 @@ SECRET_KEY_LENGTH = 10
|
||||
def get_ip_region(ip):
|
||||
reader = geoip2.database.Reader(settings.GEOIP_DATABASE_PATH)
|
||||
try:
|
||||
return reader.country(ip).country.iso_code.lower()
|
||||
iso_code = reader.country(ip).country.iso_code
|
||||
|
||||
if iso_code is None:
|
||||
return None
|
||||
|
||||
return iso_code.lower()
|
||||
except geoip2.errors.AddressNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user