首页 > 解决方案 > Django Inline Formset Clean 方法不会在模板中引发验证错误?

问题描述

我正在使用内联表单集,我使用了干净的方法,但干净的方法没有引发错误,我也使用了'{{ formset.non_form_errors }}'。下面的 clean 方法截断了打印语句到达最后一刻,直到没有引发验证错误后到达。为什么 ?

        if self.instance.tax not in (None, ''):
            if total != self.instance.tax:
                self.errors.append({"error":"The Sum of different Tax Breakups should be equal to total TAX rate"})
                print("reaching last moment")

                raise forms.ValidationError("The Sum of different Tax Breakups should be equal to total TAX rate")

标签: djangodjango-modelsdjango-viewsdjango-formsdjango-templates

解决方案


推荐阅读