嗨,我有django表单模型,我想要为它添加我的自定义类,但我仍然得到错误:
TypeError:init()得到一个意外的关键字参数'attrs'
我的django代码:
class ContactForm(forms.ModelForm):
class Meta:
model = ContactFormModel
fields = ('name', 'email', 'phoneNumber',
'message',)
widgets = {
'name': CharField(attrs={'class': 'myfieldclass'}),
}
谢谢你的帮助 .
1 回答
CharField
不是小部件,但TextInput是!