Python Forum
ValidationError doesn't get printed in my web
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ValidationError doesn't get printed in my web
#1
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.
Reply
#2
What about your view? You probably forget to call yourform.is_valid() in your corresponding view function.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020