{"title":"Geolocation with GeoIP2","version":"4.2","locale":"el","docname":"ref/contrib/gis/geoip2","url":"/el/4.2/ref/contrib/gis/geoip2/","canonical":"https://djangodocs.dev/el/4.2/ref/contrib/gis/geoip2/","summary":"The GeoIP2 object is a wrapper for the MaxMind geoip2 Python library . [ 1 ] In order to perform IP-based geolocation, the GeoIP2 object requires the geoip2 Python…","html":"<span id=\"geolocation-with-geoip2\"></span><h1>Geolocation with GeoIP2<a class=\"heading-anchor\" href=\"#module-django.contrib.gis.geoip2\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>The <a class=\"reference internal\" href=\"#django.contrib.gis.geoip2.GeoIP2\" title=\"django.contrib.gis.geoip2.GeoIP2\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">GeoIP2</span></code></a> object is a wrapper for the <a class=\"reference external\" href=\"https://geoip2.readthedocs.io/\">MaxMind geoip2 Python\nlibrary</a>. <a class=\"footnote-reference brackets\" href=\"#id6\" id=\"id1\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>1<span class=\"fn-bracket\">]</span></a></p>\n<p>In order to perform IP-based geolocation, the <a class=\"reference internal\" href=\"#django.contrib.gis.geoip2.GeoIP2\" title=\"django.contrib.gis.geoip2.GeoIP2\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">GeoIP2</span></code></a> object requires\nthe <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/geoip2/\">geoip2</a> Python package and the GeoIP <code class=\"docutils literal notranslate\"><span class=\"pre\">Country</span></code> and/or <code class=\"docutils literal notranslate\"><span class=\"pre\">City</span></code>\ndatasets in binary format (the CSV files will not work!), downloaded from e.g.\n<a class=\"reference external\" href=\"https://dev.maxmind.com/geoip/geolite2-free-geolocation-data\">MaxMind</a> or <a class=\"reference external\" href=\"https://db-ip.com/db/lite.php\">DB-IP</a> websites. Grab the <code class=\"docutils literal notranslate\"><span class=\"pre\">GeoLite2-Country.mmdb.gz</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">GeoLite2-City.mmdb.gz</span></code> files and unzip them in a directory corresponding to\nthe <a class=\"reference internal\" href=\"#std-setting-GEOIP_PATH\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">GEOIP_PATH</span></code></a> setting.</p>\n<p>Additionally, it is recommended to install the <a class=\"reference external\" href=\"https://github.com/maxmind/libmaxminddb/\">libmaxminddb C library</a>, so\nthat <code class=\"docutils literal notranslate\"><span class=\"pre\">geoip2</span></code> can leverage the C library’s faster speed.</p>\n<aside class=\"version-note version-changed\" data-version=\"4.2\">\n<p class=\"version-note-title\">Changed in Django 4.2</p><p>Support for <code class=\"docutils literal notranslate\"><span class=\"pre\">.mmdb</span></code> files downloaded from DB-IP was added.</p>\n</aside>\n<section id=\"example\">\n<h2>Example<a class=\"heading-anchor\" href=\"#example\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Here is an example of its usage:</p>\n<div class=\"code-block\" data-language=\"pycon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python console</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python console code\"><code><span class=\"gp\">&gt;&gt;&gt; </span><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.contrib.gis.geoip2</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">GeoIP2</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span> <span class=\"o\">=</span> <span class=\"n\">GeoIP2</span><span class=\"p\">()</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span><span class=\"o\">.</span><span class=\"n\">country</span><span class=\"p\">(</span><span class=\"s2\">&quot;google.com&quot;</span><span class=\"p\">)</span>\n<span class=\"go\">{&#39;country_code&#39;: &#39;US&#39;, &#39;country_name&#39;: &#39;United States&#39;}</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span><span class=\"o\">.</span><span class=\"n\">city</span><span class=\"p\">(</span><span class=\"s2\">&quot;72.14.207.99&quot;</span><span class=\"p\">)</span>\n<span class=\"go\">{&#39;city&#39;: &#39;Mountain View&#39;,</span>\n<span class=\"go\">&#39;continent_code&#39;: &#39;NA&#39;,</span>\n<span class=\"go\">&#39;continent_name&#39;: &#39;North America&#39;,</span>\n<span class=\"go\">&#39;country_code&#39;: &#39;US&#39;,</span>\n<span class=\"go\">&#39;country_name&#39;: &#39;United States&#39;,</span>\n<span class=\"go\">&#39;dma_code&#39;: 807,</span>\n<span class=\"go\">&#39;is_in_european_union&#39;: False,</span>\n<span class=\"go\">&#39;latitude&#39;: 37.419200897216797,</span>\n<span class=\"go\">&#39;longitude&#39;: -122.05740356445312,</span>\n<span class=\"go\">&#39;postal_code&#39;: &#39;94043&#39;,</span>\n<span class=\"go\">&#39;region&#39;: &#39;CA&#39;,</span>\n<span class=\"go\">&#39;time_zone&#39;: &#39;America/Los_Angeles&#39;}</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span><span class=\"o\">.</span><span class=\"n\">lat_lon</span><span class=\"p\">(</span><span class=\"s2\">&quot;salon.com&quot;</span><span class=\"p\">)</span>\n<span class=\"go\">(39.0437, -77.4875)</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span><span class=\"o\">.</span><span class=\"n\">lon_lat</span><span class=\"p\">(</span><span class=\"s2\">&quot;uh.edu&quot;</span><span class=\"p\">)</span>\n<span class=\"go\">(-95.4342, 29.834)</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"n\">g</span><span class=\"o\">.</span><span class=\"n\">geos</span><span class=\"p\">(</span><span class=\"s2\">&quot;24.124.1.80&quot;</span><span class=\"p\">)</span><span class=\"o\">.</span><span class=\"n\">wkt</span>\n<span class=\"go\">&#39;POINT (-97 38)&#39;</span>\n</code></pre></div>\n</section>\n<section id=\"api-reference\">\n<h2>API Reference<a class=\"heading-anchor\" href=\"#api-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GeoIP2</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">path</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">cache</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">0</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">country</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">city</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">GeoIP</span></code> object does not require any parameters to use the default\nsettings. However, at the very least the <a class=\"reference internal\" href=\"#std-setting-GEOIP_PATH\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">GEOIP_PATH</span></code></a> setting\nshould be set with the path of the location of your GeoIP datasets. The\nfollowing initialization keywords may be used to customize any of the\ndefaults.</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Keyword Arguments</p></th>\n<th class=\"head\"><p>Description</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">path</span></code></p></td>\n<td><p>Base directory to where GeoIP data is located or the\nfull path to where the city or country data files\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">.mmdb</span></code>) are located. Assumes that both the city and\ncountry datasets are located in this directory;\noverrides the <a class=\"reference internal\" href=\"#std-setting-GEOIP_PATH\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">GEOIP_PATH</span></code></a> setting.</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">cache</span></code></p></td>\n<td><p>The cache settings when opening up the GeoIP datasets. May\nbe an integer in (0, 1, 2, 4, 8) corresponding to the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">MODE_AUTO</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">MODE_MMAP_EXT</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">MODE_MMAP</span></code>, and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">GEOIP_INDEX_CACHE</span></code> <code class=\"docutils literal notranslate\"><span class=\"pre\">MODE_MEMORY</span></code> C API settings,\nrespectively. Defaults to 0 (<code class=\"docutils literal notranslate\"><span class=\"pre\">MODE_AUTO</span></code>).</p></td>\n</tr>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">country</span></code></p></td>\n<td><p>The name of the GeoIP country data file. Defaults\nto <code class=\"docutils literal notranslate\"><span class=\"pre\">GeoLite2-Country.mmdb</span></code>. Setting this keyword\noverrides the <a class=\"reference internal\" href=\"#std-setting-GEOIP_COUNTRY\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">GEOIP_COUNTRY</span></code></a> setting.</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">city</span></code></p></td>\n<td><p>The name of the GeoIP city data file. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">GeoLite2-City.mmdb</span></code>. Setting this keyword overrides\nthe <a class=\"reference internal\" href=\"#std-setting-GEOIP_CITY\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">GEOIP_CITY</span></code></a> setting.</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n</section>\n<section id=\"methods\">\n<h2>Methods<a class=\"heading-anchor\" href=\"#methods\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"instantiating\">\n<h3>Instantiating<a class=\"heading-anchor\" href=\"#instantiating\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.open\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">classmethod</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">open</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">path</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">cache</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.open\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This classmethod instantiates the GeoIP object from the given database path\nand given cache setting.</p>\n</section>\n<section id=\"querying\">\n<h3>Querying<a class=\"heading-anchor\" href=\"#querying\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All the following querying routines may take either a string IP address\nor a fully qualified domain name (FQDN). For example, both\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'205.186.163.125'</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">'djangoproject.com'</span></code> would be valid query\nparameters.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.city\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">city</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.city\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a dictionary of city information for the given query. Some\nof the values in the dictionary may be undefined (<code class=\"docutils literal notranslate\"><span class=\"pre\">None</span></code>).</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.country\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">country</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.country\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a dictionary with the country code and country for the given\nquery.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.country_code\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">country_code</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.country_code\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns the country code corresponding to the query.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.country_name\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">country_name</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.country_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns the country name corresponding to the query.</p>\n</section>\n<section id=\"coordinate-retrieval\">\n<h3>Coordinate Retrieval<a class=\"heading-anchor\" href=\"#coordinate-retrieval\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.coords\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">coords</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.coords\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a coordinate tuple of (longitude, latitude).</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.lon_lat\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">lon_lat</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.lon_lat\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a coordinate tuple of (longitude, latitude).</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.lat_lon\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">lat_lon</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.lat_lon\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a coordinate tuple of (latitude, longitude),</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2.geos\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">GeoIP2.</span></span><span class=\"sig-name descname\"><span class=\"pre\">geos</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">query</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2.geos\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns a <a class=\"reference internal\" href=\"/el/4.2/ref/contrib/gis/geos/#django.contrib.gis.geos.Point\" title=\"django.contrib.gis.geos.Point\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Point</span></code></a> object corresponding to the\nquery.</p>\n</section>\n</section>\n<section id=\"settings\">\n<h2>Settings<a class=\"heading-anchor\" href=\"#settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"geoip-path\">\n<span id=\"std-setting-GEOIP_PATH\"></span><h3><code class=\"docutils literal notranslate\"><span class=\"pre\">GEOIP_PATH</span></code><a class=\"heading-anchor\" href=\"#geoip-path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A string or <a class=\"reference external\" href=\"https://docs.python.org/3/library/pathlib.html#pathlib.Path\" title=\"(στη Python έκδοση 3.14)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">pathlib.Path</span></code></a> specifying the directory where the GeoIP data\nfiles are located. This setting is <em>required</em> unless manually specified\nwith <code class=\"docutils literal notranslate\"><span class=\"pre\">path</span></code> keyword when initializing the <a class=\"reference internal\" href=\"#django.contrib.gis.geoip2.GeoIP2\" title=\"django.contrib.gis.geoip2.GeoIP2\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">GeoIP2</span></code></a> object.</p>\n</section>\n<section id=\"geoip-country\">\n<span id=\"std-setting-GEOIP_COUNTRY\"></span><h3><code class=\"docutils literal notranslate\"><span class=\"pre\">GEOIP_COUNTRY</span></code><a class=\"heading-anchor\" href=\"#geoip-country\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The basename to use for the GeoIP country data file. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'GeoLite2-Country.mmdb'</span></code>.</p>\n</section>\n<section id=\"geoip-city\">\n<span id=\"std-setting-GEOIP_CITY\"></span><h3><code class=\"docutils literal notranslate\"><span class=\"pre\">GEOIP_CITY</span></code><a class=\"heading-anchor\" href=\"#geoip-city\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The basename to use for the GeoIP city data file. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'GeoLite2-City.mmdb'</span></code>.</p>\n</section>\n</section>\n<section id=\"exceptions\">\n<h2>Exceptions<a class=\"heading-anchor\" href=\"#exceptions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py exception\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.gis.geoip2.GeoIP2Exception\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">exception</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GeoIP2Exception</span></span><a class=\"heading-anchor\" href=\"#django.contrib.gis.geoip2.GeoIP2Exception\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The exception raised when an error occurs in a call to the underlying\n<code class=\"docutils literal notranslate\"><span class=\"pre\">geoip2</span></code> library.</p>\n</dd></dl>\n\n<p class=\"rubric\">Footnotes</p>\n<aside class=\"footnote-list brackets\">\n<aside class=\"footnote brackets\" id=\"id6\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id1\">1</a><span class=\"fn-bracket\">]</span></span>\n<p>GeoIP(R) is a registered trademark of MaxMind, Inc.</p>\n</aside>\n</aside>\n</section>","rootId":"module-django.contrib.gis.geoip2","toc":[{"title":"Example","anchor":"example","children":[]},{"title":"API Reference","anchor":"api-reference","children":[]},{"title":"Methods","anchor":"methods","children":[{"title":"Instantiating","anchor":"instantiating","children":[]},{"title":"Querying","anchor":"querying","children":[]},{"title":"Coordinate Retrieval","anchor":"coordinate-retrieval","children":[]}]},{"title":"Settings","anchor":"settings","children":[{"title":"GEOIP_PATH","anchor":"geoip-path","children":[]},{"title":"GEOIP_COUNTRY","anchor":"geoip-country","children":[]},{"title":"GEOIP_CITY","anchor":"geoip-city","children":[]}]},{"title":"Exceptions","anchor":"exceptions","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/el/4.2/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/el/4.2/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/el/4.2/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/gdal","title":"GDAL API","url":"/el/4.2/ref/contrib/gis/gdal/"},"next":{"docname":"ref/contrib/gis/utils","title":"GeoDjango Utilities","url":"/el/4.2/ref/contrib/gis/utils/"},"formats":{"html":"/el/4.2/ref/contrib/gis/geoip2/","markdown":"/el/4.2/ref/contrib/gis/geoip2.md","json":"/el/4.2/ref/contrib/gis/geoip2.json"},"source":"https://github.com/django/django/blob/stable/4.2.x/docs/ref/contrib/gis/geoip2.txt","official":"https://docs.djangoproject.com/el/4.2/ref/contrib/gis/geoip2/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}