This app works with python 2.7, 3.4+, Django 1.10 and higher.

Recommended way to install is via pip:

pip install django-geoip


  • Add django_geoip to INSTALLED_APPS in

  • Create application tables in database:

    python migrate
  • Obtain latest data to perform geoip detection by running management command:

    python geoip_update


In order to make user’s location detection automatic several other steps are required:

  • Add LocationMiddleware to MIDDLEWARE_CLASSES:

    MIDDLEWARE = (...
  • Provide a custom location model (inherited from django_geoip.models.GeoLocationFacade)

  • Specify this model in Settings:

    GEOIP_LOCATION_MODEL = 'example.models.Location' # just an example, replace with your own
  • Include app urls into your urlconf if you want to allow visitors to change their location:

    urlpatterns += [
        url(r'^geoip/', include('django_geoip.urls')),
  • Add local ISO codes if you want to change or add countries in Settings:

        "RU": "Российская Федерация",