From 9473a8481a29ff6272664b19eeb91bfc3640f705 Mon Sep 17 00:00:00 2001 From: Ryan Verner Date: Wed, 25 Oct 2017 19:30:42 +1100 Subject: [PATCH] Fixed #28740 -- Added 'continent_code' and 'continent_name' in GeoIP2.city() dict. --- django/contrib/gis/geoip2/resources.py | 2 ++ docs/ref/contrib/gis/geoip2.txt | 2 ++ tests/gis_tests/test_geoip2.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/django/contrib/gis/geoip2/resources.py b/django/contrib/gis/geoip2/resources.py index 967fe0a5a9..2ba5d8ac31 100644 --- a/django/contrib/gis/geoip2/resources.py +++ b/django/contrib/gis/geoip2/resources.py @@ -1,6 +1,8 @@ def City(response): return { 'city': response.city.name, + 'continent_code': response.continent.code, + 'continent_name': response.continent.name, 'country_code': response.country.iso_code, 'country_name': response.country.name, 'dma_code': response.location.metro_code, diff --git a/docs/ref/contrib/gis/geoip2.txt b/docs/ref/contrib/gis/geoip2.txt index b6622edb52..aba7995c0a 100644 --- a/docs/ref/contrib/gis/geoip2.txt +++ b/docs/ref/contrib/gis/geoip2.txt @@ -33,6 +33,8 @@ Here is an example of its usage:: {'country_code': 'US', 'country_name': 'United States'} >>> g.city('72.14.207.99') {'city': 'Mountain View', + 'continent_code': 'NA', + 'continent_name': 'North America', 'country_code': 'US', 'country_name': 'United States', 'dma_code': 807, diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py index f28f8da1e1..a2f5a08dd2 100644 --- a/tests/gis_tests/test_geoip2.py +++ b/tests/gis_tests/test_geoip2.py @@ -115,6 +115,8 @@ class GeoIPTest(unittest.TestCase): # City information dictionary. d = g.city(query) + self.assertEqual('NA', d['continent_code']) + self.assertEqual('North America', d['continent_name']) self.assertEqual('US', d['country_code']) self.assertEqual('Houston', d['city']) self.assertEqual('TX', d['region'])