Under the hood

Data storage

All geoip data, including geograpy and geoip mapping is stored in the database. To avoid unnecessary database hits user location id is stored in a cookie.

Geography

Right now django-geoip supports only ipgeobase geography, which consist of following entities: Country, Region, City. Database maintains normalized relationships between all entities, i.e. Country has many Regions, Region has many Cities.

class django_geoip.models.Country(*args, **kwargs)

One country per row, contains country code and country name.

class django_geoip.models.Region(*args, **kwargs)

Region is a some geographical entity that belongs to one Country, Cities belong to one specific Region. Identified by country and name.

class django_geoip.models.City(*args, **kwargs)

Geopoint that belongs to the Region and Country. Identified by name and region. Contains additional latitude/longitude info.

IP ranges

class django_geoip.models.IpRange(*args, **kwargs)

IP ranges are stored in separate table, one row for each ip range.

Each range might be associated with either country (for IP ranges outside of Russia and Ukraine) or country, region and city together.

Ip range borders are stored as long integers

Backends

There is currently no infrastructure to use alternative geoip backends, but it’s planned for future releases.

Ipgeobase backend

ipgeobase.ru is a database of russian and ukranian IP networks mapped to geographical locations.

It’s maintained by RuCenter and updated daily.

As of 9 April 2012 it contains info on 952 cities and 145736 Ip Ranges (some networks doesn’t belong to CIS).

Here a is demo of ip detection: http://ipgeobase.ru/

Project Versions

Table Of Contents

Previous topic

Usage

Next topic

Updating GeoIP database

This Page