Created
March 2, 2012 13:55
-
-
Save ejucovy/1958529 to your computer and use it in GitHub Desktop.
django geoip in a request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.utils import GeoIP | |
def my_view(request): | |
ip_addr = request.META.get("REMOTE_ADDR") | |
assert ip_addr is not None | |
g = GeoIP() | |
lat, lng = g.lat_lon(ip_addr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment