你好,我试图清理我的usercreationform使用小部件,但它不工作。类没有被传递'形式控制',但它的工作模型形式。不知道我做错了什么?我是新的。
forms.py
class ProfileForm(UserCreationForm):
class Meta:
model=User
fields = ('email', 'avatar', 'password1', 'password2')
def __init__(self, *args, **kwargs):
super(ProfileForm, self).__init__(*args, **kwargs)
self.fields['email'].widget.attrs['class'] = 'form-control'
self.fields['password1'].widget.attrs['class'] = 'form-control'
self.fields['password2'].widget.attrs['class'] = 'form-control'
class CustomerForm(ModelForm):
class Meta:
model = Customer
fields = ['name','email','phone_number' ]
widgets={
'name' :forms.TextInput(attrs={'class':'form-control'}),
'email' :forms.TextInput(attrs={'class':'form-control'}),
'phone_number' :forms.TextInput(attrs={'class':'form-control'}),
}
1条答案
按热度按时间vtwuwzda1#