Реализую авторизацию с регистрацией на django. Регистрация прошла успешна, но при попытке авторизоваться выходит ошибка "__all__
Please enter a correct username and password. Note that both fields may be case-sensitive." Пароль и юзернэйм ввожу корректные перепроверял.
Код:
class RegisterView(CreateView):
model = User
fields = ['username', 'password1']
success_url = reverse_lazy('element_one:profile')
def form_valid(self, form):
form.instance.created_by = self.request.user
return super().form_valid(form)
class User(AbstractBaseUser, PermissionsMixin):
password1 = models.CharField(max_length=200)
password2 = models.CharField(max_length=200)
username = models.CharField(max_length=255, unique=True)
first_name = models.CharField(max_length=30, null=True, blank=True)
last_name = models.CharField(max_length=30, null=True, blank=True)
email = models.EmailField(max_length=255, unique=True)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField(u'date joined', default=timezone.now)
objects = UserManager()
avatar = models.ImageField(settings.AUTH_USER_MODEL, default='media/no_image.jpg', blank=True)
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['email', 'password', 'avatar']
class RegistrationForm(UserCreationForm):
username = forms.CharField(label='Имя пользователя', widget=forms.TextInput(attrs={'class': 'form-control'}))
email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={'class': 'form-control'}))
password1 = forms.CharField(label='Пароль', widget=forms.PasswordInput(attrs={'class': 'form-control'}))
password2 = forms.CharField(label='Подтверждение пароля',
widget=forms.PasswordInput(attrs={'class': 'form-control'}))
class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')