'Useradmincreatinform' Object has no attribute 'get' Django

Asked

Viewed 43 times

1

I was trying to send data from a user to the database and received the following error. inserir a descrição da imagem aqui

from django import forms
from django.contrib.auth.forms import UserCreationForm
#from django.contrib.auth import get_user_model
from django.contrib.auth.forms import ReadOnlyPasswordHashField
from .models import User

class UserAdminCreatinForm(forms.ModelForm):
    password1 = forms.CharField(label='senha', widget=forms.PasswordInput)
    password2 = forms.CharField(label='confimar senha', widget=forms.PasswordInput)

    def clean_password2(self):
        password1 = self.cleaned_data.get('password1')
        password2 = self.cleaned_data.get('password2')

        if password1 and password2 and password1 != password2:
            raise forms.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']
  • Put the error text that is generated in the terminal, by the image of p not see all

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.