我有两个表单发送到模板,当我收到它们时,所有模型都被检索并保存,但最后一个模型采用所有其他模型并保存自身,而且它也不会保存自身。我收到如下错误。有人可以帮我吗?
Exception Type: TypeError
Exception Value: int() argument must be a string or a number, not 'tuple'
我找到了它,问题看起来只是从表单中输入的一个问题,它是从表单中看到的
class AForm(ModelForm):
mentancy_fee = forms.IntegerField(required=False)
这里是模型的定义
class AgentLandLordContract(models.Model):
mentancy_fee = models.IntegerField(default=0,blank=True,null = True)
那么为什么这个表单字段返回一个元组而不是它。我只从表单中屏蔽了这个文件,一切都很好
最佳答案
在表单中,我在字段末尾留下了一个逗号,这使得表单输入到一个元组中,当我发现一切正常时
mentancy_fee = forms.IntegerField(required=False),
关于django - 保存模型 int() 参数必须是字符串或数字,而不是 'tuple',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14592203/