I have the following code for my login:
class LoginForm(forms.Form):
email = forms.EmailField(max_length = 254, min_length = 6)
password = forms.CharField(min_length = 8, widget = forms.PasswordInput())
def Login(self):
email = self.cleaned_data.get('email')
password = self.cleaned_data.get('password')
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 user
However when I have debug set to false on my site, whenever the login is incorrect I get a 500 error instead of the form displaying the ValidationError. I am calling it like:
if form.is_valid():
user = form.Login()
That is in a view method. What am I missing here? How do I properly call this form error so it doesn't 500 when debug is set to false?