[Answer]-How to get Django form method to not 500 when debug is false on raising a form error?

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

Leave a comment