yunojuno / django-geoip2-extras

Additional functionality using the GeoIP2 database and functions.
MIT License
8 stars 4 forks source link

Convert project to use cache instead of session #8

Closed hugorodgerbrown closed 3 years ago

hugorodgerbrown commented 6 years ago

Reboot of the project, emerging from #7, that uses django.core.cache instead of session storage. There's no reason to store the geodata in the session, when the IP address may be shared amongst users.

In addition, I have removed the custom GeoData class, and just used the django.contrib.gis.geoip2 dict instead - it's not as user friendly, but it is simple.

>>> request.remote_addr
'1.2.3.4'
>>> request.geo_data
{
    "remote_addr": "1234",
    "country_code": "XX",
    "country_name": "unknown"
}
hugorodgerbrown commented 3 years ago

Closing in favour of #12