{"id":16469756,"url":"https://github.com/vinitkumar/django-geoip-redirection","last_synced_at":"2025-10-27T12:05:22.380Z","repository":{"id":16424692,"uuid":"19175951","full_name":"vinitkumar/django-geoip-redirection","owner":"vinitkumar","description":"GeoIP based redirection middleware for django","archived":false,"fork":false,"pushed_at":"2014-07-05T18:21:12.000Z","size":636,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T06:11:15.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vinitkumar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-26T11:39:44.000Z","updated_at":"2020-04-07T17:38:45.000Z","dependencies_parsed_at":"2022-09-17T00:21:31.336Z","dependency_job_id":null,"html_url":"https://github.com/vinitkumar/django-geoip-redirection","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitkumar%2Fdjango-geoip-redirection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitkumar%2Fdjango-geoip-redirection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitkumar%2Fdjango-geoip-redirection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitkumar%2Fdjango-geoip-redirection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinitkumar","download_url":"https://codeload.github.com/vinitkumar/django-geoip-redirection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508565,"owners_count":19484161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T12:08:46.334Z","updated_at":"2025-10-27T12:05:17.337Z","avatar_url":"https://github.com/vinitkumar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/vinitkumar/django-geoip-redirection.svg?branch=master)](https://travis-ci.org/vinitkumar/django-geoip-redirection)\n\nDjango-geoip-redirection\n========================\n\n![World Map](https://i.cloudup.com/7rf2v_IDxv-2000x2000.png)\n\nGeoIP based redirection is awesome and achieving it isn't too hard either. I wrote this middleware \nto ensure that my website would get redirected properly with regards to the location of the user\naccessing the website.\n\n\n## Usage:\n\nInstall via pypi: `pip install django_geoip_redirection`\n\n\nAdd the middleware in your settings file:\n\n```python\nMIDDLEWARE_CLASSES = (\n  'django.contrib.sessions.middleware.SessionMiddleware',\n  'django.middleware.csrf.CsrfViewMiddleware',\n  'django.contrib.auth.middleware.AuthenticationMiddleware',\n  'django.contrib.messages.middleware.MessageMiddleware',\n  'cms.middleware.language.LanguageCookieMiddleware',\n  'django_geoip_redirection.middleware.LocationMiddleWare',\n)\n```\n\nAlso add `django_geoip_redirection` to INSTALLED APPS:\n\n```python\nINSTALLED_APPS = (\n  'django_geoip_redirection',\n  ....\n)\n```\n\n## Customization:\n\n```python\n# Change the array for extension as per country you \n# have to support\nif request.path[:4] in [\"/en/\", \"/nl/\", \"/in/\"]:\n    return None\n\nif 'HTTP_X_FORWARDED_FOR' in request.META:\n    request.META['REMOTE_ADDR'] = request.META['HTTP_X_FORWARDED_FOR']\nip_address = request.META['REMOTE_ADDR']\n# get country name using Maxmind database.\n# Now, just match and redirect.\n# Likewise, replace the name of country to match and redirect.\ncountry = get_country_request(ip_address)\nif country == \"India\":\n    return HttpResponseRedirect('/in/')\nelif country == \"Netherlands\":\n    return HttpResponseRedirect('/nl/')\nelse:\n    return HttpResponseRedirect('/en/')\nreturn None\n\n```\n\nYou would also need to place the `GeoIP.dat.dat` present inside the data folder to\nyour project root directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinitkumar%2Fdjango-geoip-redirection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinitkumar%2Fdjango-geoip-redirection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinitkumar%2Fdjango-geoip-redirection/lists"}