Python Forum

Full Version: ValidationError doesn't get printed in my web
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been learning django for two weeks now and I'm currently learning raising forms.Errors such as forms.ValidationError.
Here's the code I've written:

def clean_email(self, *args, **kwargs):
    email = self.cleaned_data.get('email')
    if not email.endswith("gmail.com"):
        raise forms.ValidationError("This is not a valid email")
    return email
The problem I have is when I write an email that doesn't contain gmail.com, ValidationError doesn't get printed in the web.
What about your view? You probably forget to call yourform.is_valid() in your corresponding view function.