'UserAdminCreatinForm' object has no attribute 'get' Django

0

I was trying to send data from a user to the database and received the following error.

fromdjangoimportformsfromdjango.contrib.auth.formsimportUserCreationForm#fromdjango.contrib.authimportget_user_modelfromdjango.contrib.auth.formsimportReadOnlyPasswordHashFieldfrom.modelsimportUserclassUserAdminCreatinForm(forms.ModelForm):password1=forms.CharField(label='senha',widget=forms.PasswordInput)password2=forms.CharField(label='confimarsenha',widget=forms.PasswordInput)defclean_password2(self):password1=self.cleaned_data.get('password1')password2=self.cleaned_data.get('password2')ifpassword1andpassword2andpassword1!=password2:raiseforms.ValidationError("Senhas nao conferem")
        return password2

    def save(self, commit=True):
        user = super(UserAdminCreatinForm, self).save(commit=False)
        user.set_password(self.cleaned_data['password2'])
        if commit:
            user.save()

    def get(self, response=None):
        return response.get()

    class Meta:
        model = User
        fields = ['email']
    
asked by anonymous 09.10.2018 / 21:40

0 answers