Hi,

  Reading on the documentation regarding formsets' validation:
https://docs.djangoproject.com/en/1.8/topics/forms/formsets/#custom-formset-validation

It seems that an overrided clean() method in a custom formset deriving from
forms.BaseFormSet would be called when validating a formset (in particular,
when explicitly calling Formset's is_valid() method).

Yet, it does not appear to be the case in this example:

    class CustomForm(forms.Form):
        title = forms.CharField()


    class CustomFormset(forms.BaseFormSet):
        def clean(self):
            raise forms.ValidationError("This error is always raised,
displaying it is success for the test.")


    def formset_error(request):
        FormSetClass = formset_factory(CustomForm, formset=CustomFormset,
extra=2)
        if request.method == 'POST':
            formset = FormSetClass(request.POST)
            if formset.is_valid():
                pass
        else:
            formset = FormSetClass()
    return render(request, "form.html", { 'formset': formset })

The ValidationError is not raised (as the clean() method is not invoked, as
shown by a debugger).
Is this the expected behaviour ? Or should I report a bug ?

Thank you for reading,
  Ad

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMM5h7Deo0k%3Dop0fdjyKDpzL2T0dKSKc0fPgsQFQ9v%2Bcw1tJDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to