Browse Source

修改查找ip地区的逻辑1

tanghongbin 4 years ago
parent
commit
55e404234f
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Controller/UserController.py

+ 4 - 2
Controller/UserController.py

@@ -1869,6 +1869,7 @@ class InitInfoView(View):
                 #     country = CommonService.getAddr(ip)
                 #     redisObject.set_data(key=key, val=country, expire=3600)
                 country = ''
+                user_ex = None
                 if user_ex_qs.exists():
                     update_dict = {
                         'updTime': now_time,
@@ -1877,6 +1878,7 @@ class InitInfoView(View):
                         'country': country
                     }
                     user_ex_qs.update(**update_dict)
+                    user_ex = user_ex_qs[0]
                 else:
                     create_dict = {
                         'addTime': now_time,
@@ -1886,9 +1888,9 @@ class InitInfoView(View):
                         'region': lang,
                         'country': country
                     }
-                    user_ex_qs = UserExModel.objects.create(**create_dict)
+                    user_ex = UserExModel.objects.create(**create_dict)
 
-                country_ip_qs = CountryIPModel.objects.filter(user_ex_id=user_ex_qs[0].id)
+                country_ip_qs = CountryIPModel.objects.filter(user_ex_id=user_ex.id)
                 if not country_ip_qs.exists():
                     countryIp = CountryIPModel(
                         ip=CommonService.get_ip_address(request),