我真的不明白我有这个模型有什么问题:
class Upload_files(models.Model): #uploaded files(for approval) are stored here
file=models.FileField(upload_to=""+strftime("%j", gmtime())+"/")
cont = models.ForeignKey(Contractor)
def __unicode__(self):
return self.file.name
和形式:
class uploadFile(forms.ModelForm):
file = forms.FileField(label=(u'file'))
cont = forms.ModelChoiceField(label="cont",
queryset=Contractor.objects.all(),
required = False
)
并在我在其中创建对象的方法中:
cont = Contractor.objects.get(id=contractor_id)
file = Upload_files.objects.create(file=file,cont=cont)
file.save()
这就是我得到的错误:
shoghlanah_upload_files has no column named cont_id
我无法真正理解我的代码有什么问题,所以请有什么想法吗?