[Fixed]-Django – forms.py validation issues

1👍

Your email_al_exist method never get’s called. Certainly not in the code that you have posted here anyway. You should perhaps rename it to clean_email.

def clean_email(self):
    email = self.cleaned_data['email']
    if StudentRegistration.objects.filter(email = email).exists():
        raise ValidationError("Email already exists")
    return email
👤e4c5

Leave a comment