You can try forming.is_valid(raise_exception=True)
On Thu, 20 Aug 2020 at 19:29, Ahmed Yasin <[email protected]> wrote: > > 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(): > > > > > > > # > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/2ad02f2f-68ff-4d65-bb3b-7d01caa1f5dbn%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/2ad02f2f-68ff-4d65-bb3b-7d01caa1f5dbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGyqUuUw%3DwcSROY5zGw1UcVV%3D_L%3DNN0nhYK-rY%3DYF9jbUou0Gw%40mail.gmail.com.

