Issue
I would like to redirect my users to specific location areas in my website, by detecting their location from their IP address.
What would be the best way to achieve this under Django 1.1.1 ?
Thanks
Edit: I want city based locationing on europe.
Solution
GeoDjango looks like it will suit your needs. I'm not sure exactly how you would want to direct users, but using the GeoIP API, you can do something like:
from django.contrib.gis.utils import GeoIP
g = GeoIP()
ip = request.META.get('REMOTE_ADDR', None)
if ip:
city = g.city(ip)['city']
else:
city = 'Rome' # default city
# proceed with city
The Docs explain things in great detail; I would take a moment to read through them thoroughly.
Answered By - Nick Presta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.