Django错误---'ZipCode'是此函数的无效关键字参数

时间:2017-07-23 14:09:26

标签: python django

我在尝试更新django中创建的第一个数据库时收到此错误:D我对此感到高兴,但我的错误需要您的帮助:

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

这是我用来更新数据库的代码。

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 

提前谢谢你, 科恩

2 个答案:

答案 0 :(得分:0)

您在声明模型时没有实例化该字段,因此无法识别该字段。

ZipCode= models.IntegerField()

答案 1 :(得分:0)

以下一行

ZipCode= models.IntegerField

错了。这应该是

ZipCode= models.IntegerField()

如果dB中存在行。您必须提供默认值或在整数字段中提供null = True。

models.IntegerField(null=True,blank=True)