|
@@ -41,8 +41,12 @@ class IPQuery:
|
|
|
if country_id == 'CN' and city != '':
|
|
|
city += '市'
|
|
|
|
|
|
- # ip地址信息存表
|
|
|
- IPAddr.objects.create(ip=ip, district=district, city=city, region=region, country_code=country_id)
|
|
|
+ # ip地址信息存表或更新
|
|
|
+ ip_addr_qs = IPAddr.objects.filter(ip=ip)
|
|
|
+ if ip_addr_qs.exists():
|
|
|
+ ip_addr_qs.update(district=district, city=city, region=region, country_code=country_id)
|
|
|
+ else:
|
|
|
+ IPAddr.objects.create(ip=ip, district=district, city=city, region=region, country_code=country_id)
|
|
|
|
|
|
# 确定天气城市
|
|
|
if district != '':
|