Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

GeoIP based redirection middleware

Project Description
[![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.
Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_geoip_redirection-0.1.3.tar.gz (3.9 kB) Copy SHA256 Checksum SHA256 Source Jul 5, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting