djangosnippets.org: Latest snippets tagged with 'geoip'https://djangosnippets.org/tags/geoip/2019-06-26T07:19:45.268959-05:00Geoip middleware to restrict users to a set of allowed countries
2019-06-26T07:19:45.268959-05:00pakalhttps://djangosnippets.org/snippets/10675/<p>This middleware uses Django's Geoip support (https://docs.djangoproject.com/fr/2.2/ref/contrib/gis/geoip2/), as well as axes's package helper to retrieve IP address (since Django's REMOTE_ADDR might be wrong when behind a reverse proxy).</p>
<p>Ensure your geolite DB files are up to date (eg. with https://djangosnippets.org/snippets/10674/).</p>
<p>The checker is optional, but ensures that security is not …</p>
Freely redistributableDjango management command to update local Maxmind Geoip databases
2019-06-26T07:14:46.596639-05:00pakalhttps://djangosnippets.org/snippets/10674/<p>This management command updates country and city Geolite databases from Maxmind (binary databases, not CSV ones), for use with Django's builtin Geoip utilities.</p>
Freely redistributableRedirect view based on GEO
2009-08-07T04:03:26.065432-05:00jorjunhttps://djangosnippets.org/snippets/1675/<p>Wanted a neat way to redirect views based on GeoIP determined criteria, from HTTP_REFERER. Decorator approach seemed the best way to make it straightforward to redirect views.</p>
<p>To use, installed the Max Mind Python GeoIP API : http://www.maxmind.com/app/python</p>
Freely redistributable