@@ -7,22 +7,13 @@ Geolocation with GeoIP
77.. module:: django.contrib.gis.geoip
88 :synopsis: High-level Python interface for MaxMind's GeoIP C library.
99
10- .. versionchanged:: 1.4
11-
12- .. note::
13-
14- In Django 1.4, the :class:`GeoIP` object was moved out of
15- :mod:`django.contrib.gis.utils` and into its own module,
16- :mod:`django.contrib.gis.geoip`. A shortcut is still provided
17- in ``utils``, but will be removed in Django 1.6.
18-
1910The :class:`GeoIP` object is a ctypes wrapper for the
2011`MaxMind GeoIP C API`__. [#]_ This interface is a BSD-licensed alternative
2112to the GPL-licensed `Python GeoIP`__ interface provided by MaxMind.
2213
2314In order to perform IP-based geolocation, the :class:`GeoIP` object requires
24- the GeoIP C libary and either the GeoIP `Country`__ or `City`__
25- datasets in binary format (the CSV files will not work!). These datasets may be
15+ the GeoIP C libary and either the GeoIP `Country`__ or `City`__
16+ datasets in binary format (the CSV files will not work!). These datasets may be
2617`downloaded from MaxMind`__. Grab the ``GeoLiteCountry/GeoIP.dat.gz`` and
2718``GeoLiteCity.dat.gz`` files and unzip them in a directory corresponding to what
2819you set :setting:`GEOIP_PATH` with in your settings. See the example and
@@ -58,7 +49,7 @@ usage::
5849 >>> g.lat_lon('salon.com')
5950 (37.789798736572266, -122.39420318603516)
6051 >>> g.lon_lat('uh.edu')
61- (-95.415199279785156, 29.77549934387207)
52+ (-95.415199279785156, 29.77549934387207)
6253 >>> g.geos('24.124.1.80').wkt
6354 'POINT (-95.2087020874023438 39.0392990112304688)'
6455
@@ -104,30 +95,30 @@ Defaults to ``'GeoLiteCity.dat'``.
10495
10596.. class:: GeoIP([path=None, cache=0, country=None, city=None])
10697
107- The ``GeoIP`` object does not require any parameters to use the default
98+ The ``GeoIP`` object does not require any parameters to use the default
10899settings. However, at the very least the :setting:`GEOIP_PATH` setting
109- should be set with the path of the location of your GeoIP data sets. The
110- following intialization keywords may be used to customize any of the
111- defaults.
100+ should be set with the path of the location of your GeoIP data sets. The
101+ following intialization keywords may be used to customize any of the
102+ defaults.
112103
113104=================== =======================================================
114105Keyword Arguments Description
115106=================== =======================================================
116- ``path`` Base directory to where GeoIP data is located or the
117- full path to where the city or country data files
118- (.dat) are located. Assumes that both the city and
119- country data sets are located in this directory;
107+ ``path`` Base directory to where GeoIP data is located or the
108+ full path to where the city or country data files
109+ (.dat) are located. Assumes that both the city and
110+ country data sets are located in this directory;
120111 overrides the :setting:`GEOIP_PATH` settings attribute.
121112
122113``cache`` The cache settings when opening up the GeoIP datasets,
123114 and may be an integer in (0, 1, 2, 4) corresponding to
124- the ``GEOIP_STANDARD``, ``GEOIP_MEMORY_CACHE``,
125- ``GEOIP_CHECK_CACHE``, and ``GEOIP_INDEX_CACHE``
126- ``GeoIPOptions`` C API settings, respectively.
115+ the ``GEOIP_STANDARD``, ``GEOIP_MEMORY_CACHE``,
116+ ``GEOIP_CHECK_CACHE``, and ``GEOIP_INDEX_CACHE``
117+ ``GeoIPOptions`` C API settings, respectively.
127118 Defaults to 0 (``GEOIP_STANDARD``).
128-
119+
129120``country`` The name of the GeoIP country data file. Defaults
130- to ``GeoIP.dat``. Setting this keyword overrides the
121+ to ``GeoIP.dat``. Setting this keyword overrides the
131122 :setting:`GEOIP_COUNTRY` settings attribute.
132123
133124``city`` The name of the GeoIP city data file. Defaults to
@@ -142,9 +133,9 @@ Querying
142133--------
143134
144135All the following querying routines may take either a string IP address
145- or a fully qualified domain name (FQDN). For example, both
146- ``'205.186.163.125'`` and ``'djangoproject.com'`` would be valid query
147- parameters.
136+ or a fully qualified domain name (FQDN). For example, both
137+ ``'205.186.163.125'`` and ``'djangoproject.com'`` would be valid query
138+ parameters.
148139
149140.. method:: GeoIP.city(query)
150141
@@ -153,7 +144,7 @@ of the values in the dictionary may be undefined (``None``).
153144
154145.. method:: GeoIP.country(query)
155146
156- Returns a dictionary with the country code and country for the given
147+ Returns a dictionary with the country code and country for the given
157148query.
158149
159150.. method:: GeoIP.country_code(query)
@@ -202,7 +193,7 @@ and country), and the version of the GeoIP C library (if supported).
202193GeoIP-Python API compatibility methods
203194----------------------------------------
204195
205- These methods exist to ease compatibility with any code using MaxMind's
196+ These methods exist to ease compatibility with any code using MaxMind's
206197existing Python API.
207198
208199.. classmethod:: GeoIP.open(path, cache)
0 commit comments