yf_yzl il y a 2 ans
Parent
commit
b8994838dc
2 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 2 1
      apps/Weather/models.py
  2. 2 2
      crond_script/crond_weather.py

+ 2 - 1
apps/Weather/models.py

@@ -3,7 +3,8 @@ from django.db import models
 
 class District(models.Model):
 
-    id = models.CharField("ID", max_length=64, blank=True, null=True)
+    id = models.BigIntegerField("ID", primary_key=True)
+    city_id = models.CharField("城市ID", max_length=64, blank=True, null=True)
     city = models.CharField("城市", max_length=64, blank=True, null=True)
     pid = models.CharField("PID",max_length=64,  blank=True, null=True)
 

+ 2 - 2
crond_script/crond_weather.py

@@ -68,9 +68,9 @@ def init_data():
     for k in all_city:
         print(k, "-------------")
         District.objects.get_or_create(
-            id=k[0],
+            city_id=k[0],
             defaults={
-                "id": k[0],
+                "city_id": k[0],
                 "city": k[1],
                 "pid": str(k[2])
             }