skip to navigation
skip to content

django_geoip_redirection 0.1.3

GeoIP based redirection middleware

[![Build Status](](


![World Map](

GeoIP based redirection is awesome and achieving it isn't too hard either. I wrote this middleware
to ensure that my website would get redirected properly with regards to the location of the user
accessing the website.

## Usage:

Add the middleware in your settings file:


Also add `django_geoip_redirection` to INSTALLED APPS:


## Customization:

# Change the array for extension as per country you
# have to support
if request.path[:4] in ["/en/", "/nl/", "/in/"]:
return None

if 'HTTP_X_FORWARDED_FOR' in request.META:
ip_address = request.META['REMOTE_ADDR']
# get country name using Maxmind database.
# Now, just match and redirect.
# Likewise, replace the name of country to match and redirect.
country = get_country_request(ip_address)
if country == "India":
return HttpResponseRedirect('/in/')
elif country == "Netherlands":
return HttpResponseRedirect('/nl/')
return HttpResponseRedirect('/en/')
return None


You would also need to place the `GeoIP.dat.dat` present inside the data folder to
your project root directory.  
File Type Py Version Uploaded on Size
django_geoip_redirection-0.1.3.tar.gz (md5) Source 2014-07-05 3KB
  • Downloads (All Versions):
  • 0 downloads in the last day
  • 0 downloads in the last week
  • 124 downloads in the last month