开发者

Django inline formset custom validation

Okay. I am probably just overlooking something silly. But I am having an issue with an inline form in django. I have this:

class BaseModelAFormset(forms.models.BaseInlineFormSet):
    def clean(self):
        for form in self.forms:
            print 'I am getting here'

ModelAFormset = inlineformset_factory(ModelB,ModelA, extra=1, formset=BaseModelAFormset)

My models are not really named ModelA and ModelB. I did that as an example.

Anyway, I have this formset on a page and have 2 forms in it plus a third blank one. (So two of the three forms are filled in with objects.

I hit save and I'd expect to see two "I am getting here"开发者_StackOverflow中文版 statements, but I only see one.

In the end, I am doing a count check for validation, but if the second form is never checked, my count check won't do much good. So the print statement is an intermediate step towards that. Anyone have any idea why this isn't looping right?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜