formset.is_valid() AND formset_errors?

There is something I do not understand in my view. It appears that both business_formset.is_valid() and business_formset.errors are TRUE.
When I try to display form and non form errors, it’s empty.

Could someone explain how that works? I guess I’m missing somtehing.

Here is the code:

if business_formset.has_changed():
                    if business_formset.is_valid():
                        messages.success(request, 'formulaire valide')
                        for form in business_formset:
                            if form.has_changed() and form.is_valid():
                                form.full_clean()
                                if not form.cleaned_data['beneficiary']:
                                    form.instance.beneficiary = company
                                form.save()
                            elif not form.is_valid():
                                has_form_errors = True
                                messages.warning(request,'form invalide')                        
                    if not business_formset.errors :
                        # Les données Affaires ont été mises à jour avec succès
                        messages.success(request, 'Les données Affaires ont été mises à jour.')
                    else: 
                        messages.warning(request,'erreur de formulaire')
                        for error in business_formset.non_form_errors():
                            # Ajouter chaque message d'erreur à la liste des messages d'avertissement
                            messages.warning(request, 'Erreur non form' + error)
                    for form_idx, form in enumerate(business_formset.forms):
                        for field, error_list in form.errors.items():
                            for error in error_list:
                                # Ajouter chaque message d'erreur à la liste des messages d'avertissement
                                messages.warning(request, f"Erreur dans le champ {form.fields[field].label} du formulaire {form_idx + 1}: {error}")```

While an empty list is falsy, a list containing empty lists or dicts is truthy. Since the formset.errors list is always going to contain dicts for the errors in those forms, it’s always going to test “True”. You would need to iterate over that list to determine if any of the forms contain non-empty dicts.