GeoDjango看起来很适合你的需求。我不确定你要如何直接引导用户,但是使用GeoIP API,你可以执行以下操作:
from django.contrib.gis.utils import GeoIPg = GeoIP()ip = request.meta.get('REMOTE_ADDR', None)if ip: city = g.city(ip)['city']else: city = 'Rome' # default city# proceed with city
GeoDjango看起来很适合你的需求。我不确定你要如何直接引导用户,但是使用GeoIP API,你可以执行以下操作:
from django.contrib.gis.utils import GeoIPg = GeoIP()ip = request.meta.get('REMOTE_ADDR', None)if ip: city = g.city(ip)['city']else: city = 'Rome' # default city# proceed with city