Skip to content

Instantly share code, notes, and snippets.

@ejucovy
Created March 2, 2012 13:55
Show Gist options
  • Save ejucovy/1958529 to your computer and use it in GitHub Desktop.
Save ejucovy/1958529 to your computer and use it in GitHub Desktop.
django geoip in a request
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