At least you should't call super.clean_fields() in clean() method...

Also how are you outputting errors in your template?


ti 16. heinäk. 2019 klo 5.22 Jacob Greene <[email protected]>
kirjoitti:

> Hello! Has anyone dealt with this before? It seems that my forms don't add
> the CSS class to errors raised in model.clean() or model.clean_fields()
> methods.
>
> I have a form that looks something like this:
>
> class HttpsFaxBoxForm(forms.ModelForm):
>     error_css_class = 'form_error'
>
>
> class Meta:
>     model = FaxBox
>     fields = ('outbound_cid_profile', 'id')
>
>
>
> And I run validation in my models(keep the admin page consistent) like
> this:
>
> class FaxBox(models.Model):
>
>     something = fields.CharField(max_length=100)
>
>
>     def clean(self):
>         if self.something == "shouldn't be here":
>
>             raise ValidationError('This should not be here! Please fix!')
>         super().clean_fields(exclude=None)
>
>
> But when this exception gets raised, the CSS class isn't applied to it in
> the template. Anyone know of a way to work around this? Thanks for reading!
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8cfa5a86-ccaf-47f7-8b10-93fbaaaf4386%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8cfa5a86-ccaf-47f7-8b10-93fbaaaf4386%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc%3DSMymVzxKzv%2BjeZJKobc5PUrfwYMfAccVdqk-9GnQ5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to