当前位置:  开发笔记 > 编程语言 > 正文

Django:获取SignUpForm没有属性clean_data的错误

如何解决《Django:获取SignUpForm没有属性clean_data的错误》经验,为你挑选了1个好方法。

这是东西.我不确定哪个部分出了问题.请帮帮我!:)我是一个迷茫的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

Raja Simon.. 6

那是对的,没有属性clean_data可能cleaned_data会帮助你...



1> Raja Simon..:

那是对的,没有属性clean_data可能cleaned_data会帮助你...

推荐阅读
小色米虫_524
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有