Why Django ValidationError not raising error?

28 views
Skip to first unread message

Ahmed Yasin

unread,
Aug 20, 2020, 9:59:26 AM8/20/20
to Django users

Well I believe you are more expert and experienced personality than me. I am having an error and i am using django 3.0.3 and python 3.8.5 and VS code as an IDE. I am using validationError to raise error. in forms.py i am using condition if email and varify_email fields are not match than raise error but its not raising error ....I am so tired and getting no help from anywhere.

here is my code ___

------forms.py-------
class FormName(forms.Form):
          name = forms.CharField( required=True)
          email = forms.EmailField( required=True)
          vmail = forms.EmailField( required=True)
          text = forms.CharField(widget = forms.Textarea)

def clean(value):
       cleaned_data = super().clean()
       name = cleaned_data.get("name")
       email = cleaned_data.get("email")
       vmail = cleaned_data.get("vmail")
       if email != vmail:
           raise ValidationError("Emails are not match")

--------views.py-----

def forms_web(request):
       forming = forms.FormName()
       if request.method == 'POST':
               forming = forms.FormName(request.POST)
               if forming.is_valid():






#

Arpana Mehta

unread,
Aug 20, 2020, 10:19:20 AM8/20/20
to django...@googlegroups.com
You can try 
forming.is_valid(raise_exception=True)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2ad02f2f-68ff-4d65-bb3b-7d01caa1f5dbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages