我試圖更新我在django創建的第一個數據庫時收到這個錯誤:DI很高興,但我需要你的幫助,我的錯誤:Django錯誤---'ZipCode'是這個函數的無效關鍵字參數
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 571, in __init__
raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])
TypeError: 'ZipCode' is an invalid keyword argument for this function
這是我在爲了更新DB中使用的代碼。
c = BusinessName(AccountingCode="0002", RefID="0001101002", FullName="Johny Cohen", Aliases="The Wolfies", Address="Florilor Street 42", City="IF", ZipCode="89899", State="Romania", Country="Romania", TypeofSanctions="SDN",Monitoring="Y", BatchNumber="1", FileName="mybeloved", UploadDate="2017-01-26", UploadBy="cohen", Decision="Noneed", Status="noneed", EngineDecision="noneed", WhoAdjudicated="cohen",DateOfAdjudication="2017-01-26", SdnType="Entity")
這裏是我的模型:
class BusinessName(models.Model):
AccountingCode = models.CharField(max_length=50)
RefID = models.CharField(max_length=50, default="")
FullName = models.CharField(max_length=250)
Aliases = models.CharField(max_length=250)
Address = models.CharField(max_length=500)
City= models.CharField(max_length=50)
ZipCode= models.IntegerField
State = models.CharField(max_length=250)
Country= models.CharField(max_length=250)
TypeOfSanction= models.CharField(max_length=250)
Monitoring= models.CharField(max_length=50)
BatchNumber= models.IntegerField # tr pus automat
FileName= models.CharField(max_length=250) # tr pus automat1
UploadDate = models.DateField(max_length=250) # tr pus automat
UploadBy= models.CharField(max_length=250) # tr pus automat
Decision= models.CharField(max_length=250) # tr pus Ulterior
Status= models.CharField(max_length=250) # tr pus automat
EngineDecision= models.CharField(max_length=250) # tr pus automat
WhoAdjudicated= models.CharField(max_length=250)
DateOfAdjudication= models.CharField(max_length=250)
SdnType = models.CharField(max_length=250) #Entity or Individual
謝謝你在前進, 科恩
謝謝你牛!現在問我:-----您嘗試添加不可爲空場「BatchNumber」沒有默認BUSINESSNAME;我們不能這樣做(數據庫需要一些東西來填充現有的行)。 請選擇一個修復程序: 1)現在提供一次性默認設置(將在所有現有行上爲該列設置一個空值) 2)退出,讓我在models.py中添加默認值 – Cohen