1👍
✅
call like this
def clean(self):
password = self.cleaned_data.get('password')
email = self.cleaned_data.get('email')
user = authenticate(email = email, password = password)
if (user is None) or (user is not None and user.is_active is False):
raise forms.ValidationError('Login is incorrect.')
return self.cleaned_data
def login(self,request):
user = authenticate(email = self.cleaned_data.get('email'),password = self.cleaned_data.get('password'))
user = authenticate(username=username, password=password)
return user
Source:stackexchange.com