Sfoglia il codice sorgente

修改查找ip地区的逻辑2

tanghongbin 4 anni fa
parent
commit
170bca8a41
1 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 5 5
      Controller/UserController.py

+ 5 - 5
Controller/UserController.py

@@ -3646,20 +3646,20 @@ def delete_local_account(username):
 def updateUserCountry(request):
     country_ip_qs = CountryIPModel.objects.filter()
     if country_ip_qs.exists():
-        country_ip_qs = country_ip_qs[0: 100]
+        country_ip_qs = country_ip_qs[0: 100].values()
         ids = []
         redisObject = RedisObject(db=6)
         for country_ip in country_ip_qs:
-            key = 'ip_country_{ip}'.format(ip=country_ip.ip)
+            key = 'ip_country_{ip}'.format(ip=country_ip['ip'])
             data = redisObject.get_data(key=key)
             if data:
                 country = data
             else:
-                country = CommonService.getAddr(country_ip.ip)
+                country = CommonService.getAddr(country_ip['ip'])
                 redisObject.set_data(key=key, val=country, expire=3600)
 
-            UserExModel.objects.filter(id=country_ip.user_ex_id).update(country=country)
-            ids.append(country_ip.id)
+            UserExModel.objects.filter(id=country_ip['user_ex_id']).update(country=country)
+            ids.append(country_ip['id'])
         CountryIPModel.objects.filter(id__in=tuple(ids)).delete()
     response = ResponseObject()
     return response.json(0)