mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #35092 -- Exposed extra fields for GeoIP2.country() and GeoIP2.city() responses.
This commit is contained in:
@@ -33,20 +33,28 @@ Here is an example of its usage:
|
||||
>>> from django.contrib.gis.geoip2 import GeoIP2
|
||||
>>> g = GeoIP2()
|
||||
>>> g.country("google.com")
|
||||
{'country_code': 'US', 'country_name': 'United States'}
|
||||
{'continent_code': 'NA',
|
||||
'continent_name': 'North America',
|
||||
'country_code': 'US',
|
||||
'country_name': 'United States',
|
||||
'is_in_european_union': False}
|
||||
>>> 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,
|
||||
'is_in_european_union': False,
|
||||
'latitude': 37.419200897216797,
|
||||
'longitude': -122.05740356445312,
|
||||
'postal_code': '94043',
|
||||
'region': 'CA',
|
||||
'time_zone': 'America/Los_Angeles'}
|
||||
{'accuracy_radius': 1000,
|
||||
'city': 'Mountain View',
|
||||
'continent_code': 'NA',
|
||||
'continent_name': 'North America',
|
||||
'country_code': 'US',
|
||||
'country_name': 'United States',
|
||||
'is_in_european_union': False,
|
||||
'latitude': 37.419200897216797,
|
||||
'longitude': -122.05740356445312,
|
||||
'metro_code': 807,
|
||||
'postal_code': '94043',
|
||||
'region_code': 'CA',
|
||||
'region_name': 'California',
|
||||
'time_zone': 'America/Los_Angeles',
|
||||
'dma_code': 807,
|
||||
'region': 'CA'}
|
||||
>>> g.lat_lon("salon.com")
|
||||
(39.0437, -77.4875)
|
||||
>>> g.lon_lat("uh.edu")
|
||||
|
||||
@@ -62,6 +62,14 @@ Minor features
|
||||
* :class:`~django.contrib.gis.geoip2.GeoIP2` now allows querying using
|
||||
:class:`ipaddress.IPv4Address` or :class:`ipaddress.IPv6Address` objects.
|
||||
|
||||
* :meth:`.GeoIP2.country` now exposes the ``continent_code``,
|
||||
``continent_name``, and ``is_in_european_union`` values.
|
||||
|
||||
* :meth:`.GeoIP2.city` now exposes the ``accuracy_radius`` and ``region_name``
|
||||
values. In addition the ``dma_code`` and ``region`` values are now exposed as
|
||||
``metro_code`` and ``region_code``, but the previous keys are also retained
|
||||
for backward compatibility.
|
||||
|
||||
:mod:`django.contrib.messages`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user