这是东西。我不确定哪个部分出了问题。请帮帮我! :)我是一个迷茫的ebit困惑哈哈哈
class SignUpForm(forms.ModelForm):
fname = forms.CharField(max_length=256, label="", required=True, widget=forms.TextInput(attrs={'class': 'form-control','placeholder': 'First Name','required':True}))
lname = forms.CharField(max_length=256, label="", required=True, widget=forms.TextInput(attrs={'class': 'form-control','placeholder': 'Last Name','required':True}))
email = forms.EmailField(max_length=256, label="", required=True, widget=forms.EmailInput(attrs={'class': 'form-control','placeholder': 'Email','required':True}))
emailConfirm = forms.EmailField(max_length=256, label="", required=True, widget=forms.EmailInput(attrs={'class': 'form-control','placeholder': 'Confirm email','required':True}))
password = forms.CharField(max_length=256, label="", required=True, widget=forms.PasswordInput(attrs={'class': 'form-control','placeholder': 'Password','required':True}))
datetime = forms.DateTimeInput()
class Meta:
model=SignUp
fields=['fname','lname','email','password',]
def clean_fname(self):
name = self.clean_data.get('fname')
if ' ' in name:
raise forms.ValidationError("Please do not have a space in your name.")
else:
return name
答案 0 :(得分:6)
那里没有属性clean_data
或许cleaned_data
会帮助你...
答案 1 :(得分:1)
clean_data
在以前的django版本中使用,而不是使用cleaned_data
你的问题将得到解决