我真的不明白这个模型有什么问题:
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
我真的不明白我的代码有什么问题所以请任何想法?