Python Forum
ValidationError doesn't get printed in my web - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: ValidationError doesn't get printed in my web (/thread-29489.html)



ValidationError doesn't get printed in my web - MarcJuegos_YT - Sep-05-2020

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.


RE: ValidationError doesn't get printed in my web - scidam - Sep-10-2020

What about your view? You probably forget to call yourform.is_valid() in your corresponding view function.